-1

I want to disable the empty_value by default in my form type. how to do this ?

->add('subject', 'choice', array(
          'label'  => 'Subject',
          'choices' => array(
           '1'  => 'contact.Appreciation',
           '2'  => 'contact.Feedback',
           '3'  => 'contact.Dissatisfactions',
           '4'  => 'contact.My account',
           '5'  => 'contact.Recruitment',
           '6'  => 'contact.Other',
          ),
          'attr'  => array(
           'class'  => 'form-control'
          ),
            'required'        => false,
            'empty_value'   => 'contact.Subject',
         ))
Mahdi Trimech
  • 341
  • 1
  • 7
  • 2
    Possible duplicate of [How to disable specific item in form choice type?](http://stackoverflow.com/questions/14344639/how-to-disable-specific-item-in-form-choice-type) – jahller Oct 09 '15 at 12:59

2 Answers2

0

Change required to true.

'required' => true

See documentation

Richard
  • 4,079
  • 1
  • 14
  • 17
0

There is no easy solution for this, but you can use an event listener on the PRE_BIND event.

See this for example: https://stackoverflow.com/a/14346520/606104

Community
  • 1
  • 1
jahller
  • 2,705
  • 1
  • 28
  • 30