Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Ajaxifying a set of radio buttons causes the following error when a radio button is selected:
PHP Fatal error: Call to undefined function webform_expand_select_ids() in /home/wwwroot/myproject/public/includes/form.inc on line 1724, referer: http://myproject/ajax-test
I assume webform_expand_select_ids() is not in scope when the ajax request is being processed.
Here's the hooks used to setup ajax on the radio buttons:
/**
* Implementation of hook_form_FORM_ID_alter().
*
*/
function custom_form_webform_client_form_32_alter(&$form, &$form_state, $form_id) {
$form['submitted']['choice']['#ajax'] = array(
'wrapper' => 'webform-component-options',
'callback' => 'custom_switch_fields_callback',
);
}
function custom_switch_fields_callback($form, $form_state) {
return '<strong>new output</strong>';
}
Changing the radio buttons to a select list fixes the problem as webform_expand_select_ids() processing is used for radio buttons and checkboxes only.
Comments
Comment #1
nsciaccaGetting similar error for checkboxes:
Fatal error: Call to undefined function webform_expand_checkboxes() in /Users/nicole/Sites/dev1/includes/form.inc on line 1724
hooks:
Comment #2
quicksketchSupport on custom coding is not provided in the Webform queue.
Comment #3
ardnet CreditAttribution: ardnet commentedHi quicksketch,
sorry I open again this issue.
I came across this thread when I try to debug my problem ( http://drupal.org/node/1211320 )
Turns out I got same problem like bluehut and nsciacca.
I want still to use radio button for my webform, instead of changing to select list.
And you mentioned that support on custom coding is not provided in Webform queue, sorry what's that means?
Do you have some way how to solve this kind of issue?
Thanks in advance.
Comment #4
quicksketchI'm happy to provide support on how to use Webform through the UI and fix bugs, but I don't provide support on questions about writing code.
Comment #5
yannisc CreditAttribution: yannisc commentedI got the same error: Fatal error: Call to undefined function webform_expand_checkboxes() in includes/form.inc on line 1748
Comment #6
nchar CreditAttribution: nchar commentedThe problem occurs when we have a multi page form (3 pages) and the first two pages have at least a checkbox while the last one doesn't. So the error: "Fatal error: Call to undefined function webform_expand_checkboxes() in includes/form.inc on line 1748" appears at the last page...
The problem happens because the file "componens/select.inc" is not loaded at the last page, as there is no checkbox component, but "webform_expand_checkboxes" function, which is defined in "select.inc", is called by "form_builder" in form.inc as a process;
So i think that either:
-all functions named "webform_expand_something" should be moved in webform.module so they can be accessible at anytime,
-or all components of the whole form should be included in every page... In this case the "_webform_client_form_rule_check" function should be removed.
Comment #7
quicksketchThanks @ncharalampidis, I've taken your description and posted it to the new issue at #1332100: Prevent undefined function calls in component includes. If this indeed can be reproduced out-of-box it should be a bug report.
Comment #8
Bcwald CreditAttribution: Bcwald commentedI can confirm that this does work. Moving both functions: webform_expand_checkboxes (I didnt have checkboxes but radio buttons) and also webform_expand_select_ids into the webform.module fixed this problem..
I think this is not the best method, but I wanted to confirm that accessibility in the node_load is the issue.
Also, I will mention that this doesn't only happen on a multi page form.. Mine was only a single page form.
Comment #9
cangeceiro CreditAttribution: cangeceiro commentedI am also running into this error when using ajaxified webforms. Even though my instance and a few others are using custom code, this looks like its creeping into other areas as well that are not related to custom code. Is there any plan to treat this as an actual bug and not just a support request for custom code?
Comment #10
grayb CreditAttribution: grayb commentedNo custom code, but I'm using multipage form and seeing this problem.
Comment #11
bartclarkson CreditAttribution: bartclarkson commentedI think we need to make the "without hacking webform module" solve clear to people searching for a magic snippet. Like me.
So adding to SweetCircus comment: the basic upshot at this point in time is that, in the custom module ("dev1_mod", respective to comment 1), you need the following lines of code:
If you want the whole custom module code (webform_ajax_submit.module), it follows. Special thanks to Envision (http://envisioninteractive.com/drupal/add-ajax-to-a-webform-in-drupal-7/)
Comment #12
cangeceiro CreditAttribution: cangeceiro commentedhere is how i was able to get around this issue
Comment #13
quicksketchAs a bug, we're handling this in #1332100: Prevent undefined function calls in component includes. This issue is all about custom coding (which happened to reveal the bug).