symfony - Adding custom option at form field type 'entity' -
in form builder, using entity choice field can retrieve contents of entity by:
$builder->add('manufacturer', 'entity', array( 'class' => 'manufacturer'....
everything works fine , selectbox rendered correctly @ view. however, add option @ selectbox called "add new" (it not mapped entity), result @ select box options of manufacturers plus 1 @ end add new. best symfony2 way achieve that?
public function finishview(formview $view, forminterface $form, array $options) { $new_choice = new choiceview(null, 'value', 'label'); $view->children['manufacturer']->vars['choices'][] = $new_choice; }
Comments
Post a Comment