2
我想验证我的表单。我在config文件夹中创建了validation.yml文件,我的包被注册并且文件被加载到DependencyInjection中。我得到以下错误:Symfony验证表单的两个问题
There is no extension able to load the configuration for "Developer\Forum\ForumBundle\Entity\Registration" (in /var/www/html/forum/src/Developer/Forum/ForumBundle/DependencyInjection/../Resources/config/validation.yml). Looked for namespace "Developer\Forum\ForumBundle\Entity\Registration", found none
我validation.yml:
Developer\Forum\ForumBundle\Entity\Registration:
properties:
name:
- NotBlank: ~
surname:
- NotBlank: ~
DependencyInjection:
namespace Developer\Forum\ForumBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Developer\Forum\ForumBundle\Entity\Registration;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class DeveloperForumForumExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('validation.yml');
}
}
形式本身工作正常,数据保存到数据库中,但我需要一些验证。什么不见了?
尽量简单地不要在包扩展类加载该文件。所以删除'$ loader-> load('validation.yml');' – Matteo 2015-02-08 14:55:29
没有这个,验证不起作用:( – Shepherd 2015-02-08 15:01:31
检查'config.yml'文件关于框架的部分: ... 验证:{enabled:true}' – Matteo 2015-02-08 15:09:50