You are here

function _webform_render_textfield in Webform 6.2

Same name and namespace in other branches
  1. 5.2 components/textfield.inc \_webform_render_textfield()
  2. 5 components/textfield.inc \_webform_render_textfield()
  3. 6.3 components/textfield.inc \_webform_render_textfield()
  4. 7.4 components/textfield.inc \_webform_render_textfield()
  5. 7.3 components/textfield.inc \_webform_render_textfield()

Build a form item array containing all the properties of this component.

Parameters

$component: An array of information describing the component, directly correlating to the webform_component database schema.

Return value

An array of a form item to be displayed on the client-side webform.

1 call to _webform_render_textfield()
_webform_submission_display_textfield in components/textfield.inc
Display the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".

File

components/textfield.inc, line 107
Webform module textfield component.

Code

function _webform_render_textfield($component) {
  $form_item = array(
    '#type' => $component['type'],
    '#title' => $component['name'],
    '#default_value' => _webform_filter_values($component['value'], NULL, NULL, FALSE),
    '#required' => $component['mandatory'],
    '#weight' => $component['weight'],
    '#field_prefix' => empty($component['extra']['field_prefix']) ? NULL : check_plain($component['extra']['field_prefix']),
    '#field_suffix' => empty($component['extra']['field_suffix']) ? NULL : check_plain($component['extra']['field_suffix']),
    '#description' => _webform_filter_descriptions($component['extra']['description']),
    '#attributes' => $component['extra']['attributes'],
    '#prefix' => '<div class="webform-component-' . $component['type'] . '" id="webform-component-' . $component['form_key'] . '">',
    '#suffix' => '</div>',
  );
  if ($component['extra']['disabled']) {
    $form_item['#attributes']['readonly'] = 'readonly';
  }

  // Change the 'width' option to the correct 'size' option.
  if ($component['extra']['width'] > 0) {
    $form_item['#size'] = $component['extra']['width'];
  }
  if ($component['extra']['maxlength'] > 0) {
    $form_item['#maxlength'] = $component['extra']['maxlength'];
  }
  return $form_item;
}