Skip to content
This repository

Extract empty_values of form field choice/entity type #17

Closed
althaus opened this Issue · 0 comments

2 participants

Matthias Althaus Johannes
Matthias Althaus

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

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.