Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Feb 2015 at 16:02 UTC
Updated:
15 Mar 2015 at 21:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
danchadwick commentedArgh.
What *is* present with modal forms? I'm wondering if the absence of all of op, form_id, and form_build_id would work. op is missing from ajax. form_build_id is missing from some cached forms. And apparently form_id is missing from modal forms. But are all three ever missing with a proper $_POST?
Comment #2
danchadwick commentedComment #3
grannytrolly commentedI've emailed you the dumps directly, but yes, the $_POST seems to have none of those items in it. The $form_state has 'form_id', except not under 'input' section - under a 'build_info' section instead.
This is kind of why I was asking about skipping the check. Trying to cater for structures managed by other modules sounds like a very painful approach.
Comment #4
agoradesign commentedWe've run into the same problem today. I've already looked into modal_forms' code, if they are doing some ugly workarounds in there. But it is written very cleanly. The module heavily depends on Ctools. The following lines are loading the webform (in modal_forms.pages.inc line 282+):
Before calling ctools_modal_form_wrapper(), the $form_state['input'] is empty, after it is filled with the following keys: 'js', 'ajax_html_ids', 'ajax_page_state'. I've played a bit around, even if you call drupal_build_form() directly, you'd get these keys. Seems their presence is some kind of default when using Ajax calls. I couldn't dig deeper, when and how and why they are added. Is anybody in here with a deeper knowledge of what happens internally, if you ajaxify a form, with or without Ctools?
I would recommend to enhance the webform_input_vars_check() and allow the presence of certain array keys within the $form_state['input']. I'll post a patch which works for us.
Comment #5
agoradesign commentedHere's my patch
Comment #6
danchadwick commented@agoradesign -- please remember to set the status back to active or needs review to let me know it needs attention again!
I went in a slightly different direction. Rather than coding specifically around modal form, I look for a key in the submitted data that, if there, means that the form_id should be too. Could you please try out this patch?
Comment #7
agoradesign commentedSorry, it was already the end of a long, busy day...
Thanks for your updated patch. Your approach is definitely smarter. And I've just tested it - works for me :)
Only one question: Is there a specific reason, why you switched from empty() check to !key_exists(). (array_)key_exists() will return TRUE, even if the value of 'form_id' is NULL. Is that intended?
see: http://php.net/manual/en/function.array-key-exists.php
Comment #8
grannytrolly commentedPatch in #6 works for me, with webform 7.x-4.3 and Modal Forms 7.x-1.2+16-dev. Tested normal webform, ajax'd webform via modal forms, plus conditionals page. Thank you.
Comment #9
danchadwick commented@agoradesign. Yes there is.
empty() is misused to mean "missing", which it doesn't. empty($a[b']) will be true when $b is missing, NULL, 0, '0', and empty array, etc. 99.999% of the time, $a[$b] can't be 0, but on the off chance that it can, I'm mindful when usnig empty.
If the form_id is NULL, I'd say that the form probably still completed, The $_POST would not seem to be truncated.
Thanks for the testing, folks. I'm commit this very soon.
EDIT: ninja
Comment #10
agoradesign commentedThat's what I meant. I wasn't sure, if a NULL value for the form_id would be really valid/complete. I think, you know better. Just wanted to be sure, that this change and its effect was intentional...
Ok, green lights on. Thanks for your quick reaction - looking forward to see this committed :)
Comment #12
danchadwick commented#6 committed to 7.x-4.x and 8.x. Thanks, folks.
Comment #14
danchadwick commented