Force a field to not be required

前端 未结 2 2053
再見小時候
再見小時候 2021-01-01 12:15

I am using Symfony2 and FOSUserBundle.

Just as detailed in the documentation, I have overridden and created a \"name\" property in the User entity.

I do all

相关标签:
2条回答
  • 2021-01-01 12:39
    $builder->add('name', 'text', array('label' => 'form.name','required' => false));
    
    0 讨论(0)
  • 2021-01-01 12:59

    Try to use:

    use Symfony\Component\Validator\Constraints\NotNull;
    
    
    $builder->add('name', 'text', array('label' => 'form.name',
    'constraints' => new NotNull()));
    
    0 讨论(0)
提交回复
热议问题