O'Reilly logo

Drupal 7 Webform Cookbook by Douglas Vernon Denny

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

Rendering components

Our next function will explain to Drupal how we would like our component rendered in HTML. We shall also specify other attributes, such as CSS classes and validation functions to be performed against input data. This is where the defaults and options we previously specified will play their part in affecting how users perceive and interact with our component on Webforms.

How to do it...

Let's add to our webform_imei.module file the Drupal Form API code required to render our component on a form:

/** * Render a Webform component to be part of a form. */ function _webform_render_imei($component, $value = NULL, $filter = TRUE) { $element = array( '#type' => 'textfield', '#title' => $filter ? _webform_filter_xss($component['name']) ...

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