In webform module there are a function:
function webform_client_form($form, &$form_state, $node, $submission, $is_draft = FALSE, $filter = TRUE)
So $submission value is required, but in description written that it is not required:
* @param $submission
* An object containing information about the form submission if we're
* displaying a result.
And near in function there are check for empty value:
if (empty($submission) && !empty($form_state['values']['details']['sid'])) {
So, if we call function webform_client_form() without $submission value, all works but we got the warning:
Warning: Missing argument 4 for webform_client_form() in function webform_client_form()
For fix this we must change
function webform_client_form($form, &$form_state, $node, $submission, $is_draft = FALSE, $filter = TRUE)
to
function webform_client_form($form, &$form_state, $node, $submission = NULL, $is_draft = FALSE, $filter = TRUE)
Is it correct or we must fix this in other place?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | webform_submission_parameter-1483156.patch | 820 bytes | quicksketch |
Comments
Comment #1
quicksketchThanks, this is a good suggestion. It's not actually a bug because it doesn't cause any problems in Webform module. In your own code, you can simply pass in NULL for the $submission parameter, but setting a default to NULL is a good idea. I'm moving this to a task. In the mean time just pass in NULL for your own version.
Comment #2
murzI got this warning with colorbox module each time when it render webform in iframe, so will be good if this task will be fixed.
Comment #3
quicksketch@Murz: It looks like the reason you're getting this error is because the code in #940220: Allow webforms to open in Colorbox (which I assume you're using) isn't correct. That code needs to pass in NULL for the 3rd parameter to drupal_get_form(). Ideally this will be fixed in Webform itself by making the $submission argument optional, but there's nothing to prevent the implementing module (ColorBox in this case) from fixing the problem in the calling code.
Comment #4
murzThanks, I fixed this in colorbox patch and update it in issue #940220: Allow webforms to open in Colorbox
Comment #5
quicksketchI fixed this in the 4.x branch by setting the $submission parameter to FALSE by default, since that's what gets passed in if a submission fails to be loaded. We were using NULL, array(), and FALSE interchangeably before. This should make it use FALSE consistently.
Considering this is a minor issue, I didn't backport it to the 3.x branch.
Comment #6
quicksketchComment #8
fenstratNeeds porting to 8.x-4.x.
Comment #9
fenstratCommitted and pushed 7834f3e to 8.x-4.x. Thanks!