O'Reilly logo

Drupal 7 Development by Example Beginner's Guide by Kurt Madel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — using hook_form_BASE_FORM_ID_alter to make our Webform emailfield code more generic

We will introduce another Drupal form-related hook to enable the emailfield across all Webform generated forms.

  1. In Aptana Studio, open the webform.module file found at /sites/all/modules/webform, and locate its hook_forms implementation:
    /**
    * Implements hook_forms().
    *
    * All webform_client_form forms share the same form handler
    */
    function webform_forms($form_id) {
    $forms = array();
    if (strpos($form_id, 'webform_client_form_') === 0) {
    $forms[$form_id]['callback'] = 'webform_client_form';
    }
    return $forms;
    }
    

    We are looking for the function being set as the callback of all Webform-based forms, and in this case, it is webform_client_form.

    Now that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required