-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the index of the last child of a collection to construct the element's form #13666
base: 1.8
Are you sure you want to change the base?
Conversation
hello, @delyriand I am not able to reproduce it, can you provide more detailed descriptions (maybe some screenshots?) |
Hi, we have the case with the https://github.com/monsieurbiz/SyliusRichEditorPlugin/ I have also other issues with this javascript I think I will try to correct it. Example : I have a collection in a collection The second element of the second collection is split in the first collection : If I correct the form after the first sumbit, it seems to be ok. |
It seems the post data are not correct : And the second time when it's ok : I search a little and found it's a configuration to add in my form : ->add('openings', CollectionType::class, [
'entry_type' => OpeningType::class,
'prototype_name' => '__opening__',
'label' => false, I added Put this pull request still important to avoid problems with the elements numerotation. |
We've got an issue with this PR when we edit an attribute: The issue is because A change could be: + {% if form.children|last.vars.name matches '/^\\d+$/' %}
data-index='{{ form.children|length > 0 ? form.children|last.vars.name + 1 : 0 }}'
+ {% endif %} but I don't know if it keep fixing your own issue :/ |
03f7cec
to
cf47970
Compare
Hi @AdamKasp We have this issue in form collections in AJAX, like in Rich Editor Plugin. |
Hi @GSadee can you have a look to this PR ? |
1 similar comment
Hi @GSadee can you have a look to this PR ? |
Hi @GSadee can you have a look to this PR, I've met this bug several times in the past weeks. |
When we have a CollectionType with children that have a numerical index, the "add" button can have a strange behaviour when deleting elements and adding new items.
For example, we have an array of items like this:
Previously, the JS code count the number of items, so 4, and add a new form with inputs name
my_beautiful_collection[items][4][XXXX]
. And when we submit the form, my "4" item is replace by the new "4"…Like explained in Symfony doc, I use the last collection item to calculate the index of the new element: https://symfony.com/doc/5.4/form/form_collections.html#allowing-new-tags-with-the-prototype
This patch should be applied on all still maintained branches: 1.9, 1.10, 1.11 and master