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?

Comments

quicksketch’s picture

Title: Warning: Missing argument 4 for webform_client_form() in function webform_client_form() » Set $submission parameter default to NULL in webform_client_form()
Category: bug » task
Priority: Normal » Minor

Thanks, 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.

murz’s picture

I got this warning with colorbox module each time when it render webform in iframe, so will be good if this task will be fixed.

quicksketch’s picture

@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.

murz’s picture

Thanks, I fixed this in colorbox patch and update it in issue #940220: Allow webforms to open in Colorbox

quicksketch’s picture

Version: 7.x-3.17 » 7.x-4.0-beta3
Issue summary: View changes
Status: Active » Fixed
StatusFileSize
new820 bytes

I 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.

quicksketch’s picture

Title: Set $submission parameter default to NULL in webform_client_form() » Set $submission parameter default to FALSE in webform_client_form()

  • Commit 7834f3e on 7.x-4.x by quicksketch:
    Issue #1483156: Set  parameter default to FALSE in webform_client_form...
fenstrat’s picture

Version: 7.x-4.0-beta3 » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Fixed » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.0-beta3
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed 7834f3e to 8.x-4.x. Thanks!

  • Commit 149c44f on 8.x-4.x by fenstrat:
    Issue #1483156 by quicksketch | Murz: Set $submission parameter default...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.