Skip to content

Extract empty_values of form field choice/entity type #17

Closed
althaus opened this Issue Dec 20, 2011 · 0 comments

2 participants

@althaus
althaus commented Dec 20, 2011

You can set the caption for the empty value element in select boxes generated by choice/entity form field types by just setting it to a string:

<?php
$builder->add('states', 'choice', array(
    'empty_value' => 'Choose an option',
));

This could be extracted by the bundle.

Be aware: empty_values can also be set to FALSE so that no option is generated at all. Possible solution would be to force the user to use @Ignore or to automatically check for the boolean value.

<?php
$builder->add('states', 'choice', array(
    'empty_value' => false,
));

Doc: http://symfony.com/doc/2.0/reference/forms/types/choice.html#empty-value

Cheers
Matthias

@schmittjoh schmittjoh closed this in efd01bc Jan 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.