-
-
Notifications
You must be signed in to change notification settings - Fork 14
Problem with manually setting value #34
Comments
I found out it happens only when i trigger click event on 'Add' button (opening collection subform) $('.form-collection-add').trigger('click'); then i set the value (as posted above) and after saving form i get the error. |
I will look into this. Is there a |
Yes, of course. My declaration: ->add('example', 'zenstruck_ajax_entity', array(
'placeholder' => '...',
'label' => '...',
'multiple' => false,
'class' => 'MyBundle:Entity',
'property' => 'title',
'url' => $this->ajax_route,
'required' => false)) setting it up works like a charm but there must be some major difference between triggering click action on 'Add' button and just clicking it (in this usual way everything is fine). To make my problem 100% clear. I got some selectable component and depending on selects (multiple) i 'open' desired amount of collection subforms and fill it with data. So i:
$('.form-collection-add').trigger('click');
//after passing other values to subform
$('#formId .zenstruck-ajax-entity').select2('data',{id:foo, text:bar}); Everything looks OK (filling subforms with data), selected entity on select2 looks like i did it on my own but saving form fails. Do u got any suggestions? |
I am going to try and re-create. |
Hmm, I just tried re-creating your issue and couldn't. My recreation is here: https://github.com/kbond/sandbox/tree/form-34 I have an What I tested:
|
Could you in step 1. do: $('#YourFormId .form-collection-add).trigger('click') ? When manualy i click 'Add' there is no problem for me as well. The thing i want to achieve is opening subform via javascript |
Ok, I tried that but it still worked as expected. |
Could you do a var_dump of |
When i try to manually (javascript depending on some other user actions in my form view) set entity value in my view via:
after saving from i get:
Warning: Illegal string offset 'id' in [...]/vendor/zenstruck/form-bundle/Zenstruck/Bundle/FormBundle/Form/Type/AjaxEntityType.php line 63
The text was updated successfully, but these errors were encountered: