summaryrefslogtreecommitdiffstats
path: root/functions/webform.php
blob: 580cc4fac6e2462ed81b3ad503b136612587a3b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
 * @file
 * Contains all functionality for theming webforms.
 */

/**
 * Implements hook_webform_email().
 *
 * We override this function because the XHTML DOCTYPE doesn't
 * allow <input type="email" />.
 */
function rijkshuisstijl_webform_email($variables) {
  $element = $variables['element'];

  // This IF statement is mostly in place to allow our tests to set type="text"
  // because SimpleTest does not support type="email".
  if (!isset($element['#attributes']['type'])) {
    $element['#attributes']['type'] = 'text';
  }

  // Convert properties to attributes on the element if set.
  foreach (array('id', 'name', 'value', 'size') as $property) {
    if (isset($element['#' . $property]) && $element['#' . $property] !== '') {
      $element['#attributes'][$property] = $element['#' . $property];
    }
  }
  _form_set_class($element, array('form-text', 'form-email'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}