ajax - symfony2 - How to create a form field of type "entity" without values -
ajax - symfony2 - How to create a form field of type "entity" without values -
i have form, , in there regular field of type "entity". table values taken has grown, , select box rendered makes page big ( = slow load).
so, replaced this: ->add( 'contact', 'entity', array( 'class' => 'crmcorebundle:contact', 'required' => false, 'empty_data' => null, ) )
with: ->add( 'contact', 'entity', array( 'class' => 'crmcorebundle:contact', 'choices' => array(), 'required' => false, 'empty_data' => null, ) ) render empty selectbox, , on frontend utilize ajax populate , autocomplete selectbox.
the problem when submit form, not valid. ideas?
it not pass validation because values submitting not added form component when form created. protect form accepting unauthorized values.
the proper way have ajax request form update select field on backend using form events, , update displayed select proper values.
more on form events here - http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html
ajax forms symfony2
Comments
Post a Comment