Closed (fixed)
Project:
Field collection
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jul 2012 at 08:51 UTC
Updated:
29 Aug 2016 at 18:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
karens commentedWrong project, moving.
Comment #2
andiart commentedThe same I experience. I have own ajax functionality in my form_alter function. Maybe it collides somehow with the field collection ajax call. I for my part get an answer from the ajax call but the changes aren't reflected in the browser. Tomorrow I will examine it further.
The problem seems to occur because of a html-id in my form, which doesn't correspond to the html id of the field collection. The module clears the id's cache in it's callback function for remove:
The callback trys to replace the content of a html element with id edit-field-invitee but in the html of my form the element is attributet with the an id of edit-field-invitee--2.
Comment #3
prateekjain commentedI am having the same issue, but its independent of the 'unlimited values' setting.
Let me know if you guys find the solution.
Thanks,
Prateek
Comment #4
Nick Robillard commentedI too have encountered this issue and have fixed it (at least for now). The solution is somewhat of a hack. I pull out the actual id from the POST 'ajax_html_ids' array and do the ajax commands using it. Like I say in my comment, I'm sure this could be done better. I am not that familiar with core D7 ajax stuff yet and I'm in a hurry. I'm using a bastardized version of Field Collection because I require Field Collection Table support, so a patch would be kind of useless. Here's my whole function field_collection_remove_js():
Comment #5
riseman commentedIf you get form via ajax, there is another solution.
I get hint from somewhere but i can not remember exact issue number.
but key is this.
in field_collection_remove_js function,
required inc file is not included if the parent of field collection is node type.
So, If you get a form by using ajax, you have to add required resources after calling ajax_get_form
Comment #6
tim.plunkett#5 is unrelated to this issue, that's just because you should have used form_load_include() instead.
#4 is along the right lines, but is a brittle hack, and will not work in all cases.
Comment #7
tim.plunkettComment #8
tim.plunkettThis is equally hacky, but also works for AJAX as well as failed validation.
Because of #1575060: ajax_html_ids are broken for forms with file element (encoding=multipart/form-data), the structure of $_POST['ajax_html_ids'] is variable.
Basically, unless drupal_html_id is not used on forms, or unless *every AJAX callback* uses the unset($_POST['ajax_html_ids']) hack, we need to code around this somehow.
Comment #9
tim.plunkettFor my use case, #1315900: Ctools Modal form's #id changes when validation fails actually solves the problem as well.
We likely need some core documentation that any AJAX callback that is doing form processing must unset the ajax_html_ids first.
Comment #10
jmuzz commentedI made a content type with a field collection (unlimited cardinality) that contains a text field and a file field. The content type also has its own file field.
I created a node with a bunch of field collection items with sequential values in their text fields. I edited it several times trying things like adding items and uploading files and then deleting some field collection items and then submitting the form. I didn't see anything strange happening.
What exactly is the problem behavior and how can it be duplicated?
Comment #11
iLLin commentedTo duplicate, you need to make your form AJAX. Select the add button to add another one of the fields and they press submit with a validation error. In your AJAX callback, return the complete form. Now try to remove one of your fields with the remove button. It will fail.
I have applied the patch and my form is now working as expected.
Works for me, Thanks!
Comment #12
dewalt commentedI propose patch based on using Drupal AJAX API.
It fills proper element id in 'wrapper' key of element '#ajax' property. AJAX callback was changed from page callback to ajax callback, using function field_add_more_js() as example for callback.
Comment #13
estoyausenteI have a problem removing fc items but I'm not sure if is exactly the same. For any reason, the remove button don't work and I don't know exactly why. I searched and I found several issues related with field collection removing proccess.
@dewalt This patch is work for me and resolve my problem, but like I said, I'm not sure if is the same problem, a similar problem or if it's completely different.
but... really thanks!!!!! :-)
Comment #14
rlmumfordI have what might be a different problem (that I thought might be related) where the remove button always removes the last item from the field, regardless of which row you click remove on. Applying this patch broke the module even further so that now none of the buttons do anything.
Comment #15
dewalt commented@rlmumford - As I understood, the problem is:
This works correctly on my project, where the patch used.
Can you please provide more details, about module broke with patch? What version of module you patched? Were additional modules installed, that depend on field_collection?
Comment #16
rlmumfordAh, my issue was this one.
#2456307: Item Remove Button confuses #parents and #array_parents
Comment #17
vtkachenko commentedPatch #12 works for me.
Comment #18
ybabel commentedPatch #12 worked for me
Comment #19
balintcsaba commentedPatch #12 worked for me to
Comment #20
matysek145 commentedPatch #12 worked for me to
Comment #21
estoyausenteI think that it's RBTC, 4 reviewer is enough.
Comment #22
nancydruPatch works for me; the issue in #15 did not happen on my site. Please commit.
Comment #23
roopeshnaik commentedI need this for beta5 module, here is the patch
Comment #25
roopeshnaik commentedUpdate the patch file name
Comment #26
dewalt commentedRe-uploading working patch.
Comment #27
dewalt commentedComment #29
jmuzz commentedThanks!
Comment #31
brendarossi commentedStill experiencing problems with AJAX deletion, this code patches 7.x-1.0-beta11.