You are here

function _webform_render_hidden in Webform 6.3

Same name and namespace in other branches
  1. 5.2 components/hidden.inc \_webform_render_hidden()
  2. 5 components/hidden.inc \_webform_render_hidden()
  3. 6.2 components/hidden.inc \_webform_render_hidden()
  4. 7.4 components/hidden.inc \_webform_render_hidden()
  5. 7.3 components/hidden.inc \_webform_render_hidden()

Implements _webform_render_component().

File

components/hidden.inc, line 70
Webform module hidden component.

Code

function _webform_render_hidden($component, $value = NULL, $filter = TRUE) {
  $node = isset($component['nid']) ? node_load($component['nid']) : NULL;

  // Set filtering options for "value" types, which are not displayed to the
  // end user so they do not need to be sanitized.
  $strict = $component['extra']['hidden_type'] != 'value';
  $allow_anonymous = $component['extra']['hidden_type'] == 'value';
  $default_value = $filter ? _webform_filter_values($component['value'], $node, NULL, NULL, $strict, $allow_anonymous) : $component['value'];
  if (isset($value[0])) {
    $default_value = $value[0];
  }
  $element = array(
    '#type' => 'hidden',
    '#title' => $filter ? _webform_filter_xss($component['name']) : $component['name'],
    '#weight' => $component['weight'],
    '#translatable' => array(
      'title',
    ),
  );
  if ($component['extra']['hidden_type'] == 'value') {
    $element['#type'] = 'value';
    $element['#value'] = $default_value;
  }
  else {
    $element['#type'] = 'hidden';
    $element['#default_value'] = $default_value;
  }
  return $element;
}