Fixes some PAReview issues.
[project/rijkshuisstijl.git] / functions / webform.php
1 <?php
2 /**
3 * @file
4 * Contains all functionality for theming webforms.
5 */
6
7 /**
8 * Implements hook_webform_email().
9 *
10 * We override this function because the XHTML DOCTYPE doesn't
11 * allow <input type="email" />.
12 */
13 function rijkshuisstijl_webform_email($variables) {
14 $element = $variables['element'];
15
16 // This IF statement is mostly in place to allow our tests to set type="text"
17 // because SimpleTest does not support type="email".
18 if (!isset($element['#attributes']['type'])) {
19 $element['#attributes']['type'] = 'text';
20 }
21
22 // Convert properties to attributes on the element if set.
23 foreach (array('id', 'name', 'value', 'size') as $property) {
24 if (isset($element['#' . $property]) && $element['#' . $property] !== '') {
25 $element['#attributes'][$property] = $element['#' . $property];
26 }
27 }
28 _form_set_class($element, array('form-text', 'form-email'));
29
30 return '<input' . drupal_attributes($element['#attributes']) . ' />';
31 }