I haven't really tracked down what is causing this, but here's what I did:
Built the same form 3 times. The form contains a couple fields with field_attach, one description and one "tags" field. The 2nd form fails to submit with the following stack:
atal error: Cannot unset string offsets in /Users/jacob/work/drupal-7/modules/field/field.default.inc on line 23 Call Stack: 0.0001 66224 1. {main}() /Users/jacob/work/drupal-7/index.php:0 0.0952 2506780 2. menu_execute_active_handler() /Users/jacob/work/drupal-7/index.php:22 0.0975 2612256 3. call_user_func_array() /Users/jacob/work/drupal-7/includes/menu.inc:476 0.0975 2612548 4. media_page_multiedit() /Users/jacob/work/drupal-7/includes/menu.inc:0 0.0975 2613928 5. call_user_func_array() /Users/jacob/work/drupal-7/sites/all/modules/d7_modules/media/media.pages.inc:56 0.0975 2614308 6. multiform_get_form() /Users/jacob/work/drupal-7/sites/all/modules/d7_modules/media/media.pages.inc:0 0.1337 2895096 7. drupal_build_form() /Users/jacob/work/drupal-7/sites/all/modules/d7_modules/multiform/multiform.module:91 0.1436 3072496 8. drupal_process_form() /Users/jacob/work/drupal-7/includes/form.inc:331 0.1459 3112048 9. form_execute_handlers() /Users/jacob/work/drupal-7/includes/form.inc:753 0.1459 3115004 10. media_edit_submit() /Users/jacob/work/drupal-7/includes/form.inc:1167 0.1476 3115568 11. field_attach_submit() /Users/jacob/work/drupal-7/sites/all/modules/d7_modules/media/media.pages.inc:418 0.1476 3117844 12. _field_invoke_default() /Users/jacob/work/drupal-7/modules/field/field.attach.inc:827 0.1476 3118436 13. _field_invoke() /Users/jacob/work/drupal-7/modules/field/field.attach.inc:371 0.1478 3123604 14. field_default_extract_form_values() /Users/jacob/work/drupal-7/modules/field/field.attach.inc:199
Basically, $form_state['values']['tags']['value'][LANGUAGE] should be an array, and it is for the first form, but on the 2nd form, it is an empty string. This causes a bad unset to be called in the function mentioned above which craps it out.
If I remove the tags field, it works fine. Also, if the first form has no tags field, but the 2nd one has one, it also fails (so not about the same named variable).
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 863322_same_form_id_does_not_validate.patch | 760 bytes | JacobSingh |
Comments
Comment #1
chx commentedIs there some JS problem? What's $_POST when submitting the multiform?
Comment #2
JacobSingh commentedSeems like it's not client side. When the tags field is in the first form, it looks the same as the 2nd form
But I guess when in the first form, it is transformed to being an array of values like expected, and on the 2nd it isn't...
Comment #3
JacobSingh commentedyeah, form_state['values'] on the 2nd one doesn't end up with an array in that field, but $_POST is fine. Well, I'm guessing the tags field code transforms it from an empty string (or a comma delimited string really) into the array and multiform breaks it for the 2nd form...
digging...
Comment #4
JacobSingh commentedyeah, would appear that taxonomy_autocomplete_validate() doesn't get called when in the 2nd form...
Comment #5
JacobSingh commentedAh, I think the problem is if the form_id of the first from and the 2nd form are the same:
The if stmt there will return true, so we don't validate the 2nd one. Not sure yet what the best approach is here, confirming, but I'm pretty sure this is it.
Comment #6
JacobSingh commentedSomething tells me this will not be the end of this issue, but it fixes the problem for me.
Comment #7
chx commented#766146: Support multiple forms with same $form_id on the same page implement hook_forms and use different form ids.