Symfony: How to customize the "none" label appearing on radio field choices?
forms, symfony
Solution
Use `placeholder` option to change the label for "None" radio input:
->add('color', ChoiceType::class, array(
'choices' => array('Red' => 1, 'Blue' => 2, 'Green' => 3),
'expanded' => true,
'required' => false,
'placeholder' => 'Null', // <---- \o/
));
Preview:
The placeholder option was introduced in Symfony 2.6 (doc)
Problem
I'm using radio buttons with "required" => false. This makes a "none" option appear along with my other choices. How can I customize this label (let's say I would want to display "null" instead of "none") ?