Community

Ajax Validation when using hook_form_alter with webform Select component screen

Hi,

I am very new to Drupal so please excuse my ignorance.

I am trying to modify the webform select component form to display a list of checkboxes as the input for the 'items' entry. The user would then be able to select a subset of the options to be displayed in a listbox in the webform itself. Using hook_form_alter I am able to add the checkboxes (I am struggling on how to get this stored in extra/items but that is a different matter) however ideally I would like a selector that would control whether this new input or the default input is displayed. Here is simplified code where an ajax call is made but with no changes:

<?php
function webform_options_form_webform_component_edit_form_alter(&$form, &$form_state, $form_id) {

   
   
$form['eas_Selector'] = array(   
     
'#type' => 'select',
     
'#title' => t('EAS Subscribers'),
     
'#options' => array(
           
'Yes' => 'Yes',
           
'No' => 'No',
        ),
     
'#default_value' => "No",
     
'#description' => t('Use this to add EAS Subscribers'),
     
'#weight' => 1,
     
'#ajax' => array(
           
// When 'event' occurs, Drupal will perform an ajax request in the
            // background. Usually the default value is sufficient (eg. change for
            // select elements), but valid values include any jQuery event,
            // most notably 'mousedown', 'blur', and 'submit'.
           
'callback' => 'webform_options_ajax_callback',
           
'wrapper' => 'eas_fieldset',
        ),
    );
   
$form['eas_Selector']['#prefix'] = '<div id="eas_fieldset">';
   
$form['eas_Selector']['#suffix'] = '</div>';



function
webform_options_ajax_callback($form, $form_state){
   
    return
$form;
}
?>

When eas_Selector is changed I recieve the following ajax error:
Fatal error: Call to undefined function _webform_edit_validate_options()

This function is defined in webform/components/select.inc and is linked to the options element module. I have read that I should use module_load_include but this has no effect. I wondered if someone could give me some guidance on where my error may be.

Thanks,

David