You are here

function theme_webform_node_element_node in Webform Node Element 7

Override for theme_webform_element().

This renders a webform node element and tacks the chosen node content onto the end of the hidden form field.

File

components/node.inc, line 260
Webform module node component.

Code

function theme_webform_node_element_node($variables) {
  $element = $variables['element'];

  // You know what? We're always a node.
  $type = 'node';
  $parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));
  $wrapper_classes = array(
    'form-item',
    'webform-component',
    'webform-component-' . $type,
  );
  if (isset($element['#webform_component']['extra']['title_display']) && $element['#webform_component']['extra']['title_display'] == 'inline') {
    $wrapper_classes[] = 'webform-container-inline';
  }
  $output = '<div class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n";
  $required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : '';

  // If #title is not set, we don't display any label or required marker.
  if (!isset($element['#title'])) {
    $element['#webform_component']['extra']['title_display'] = 'none';
  }
  $prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : '';
  $suffix = isset($element['#field_suffix']) ? '<span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : '';

  // Because we're a hidden field, the rendered node content won't show up
  // on the page. However, #field_value congtains a copy. Tack that on to
  // the element output here.
  $value = isset($element['#field_value']) ? '<span class="field-value">' . $element['#field_value'] . '</span> ' : '';
  switch ($element['#webform_component']['extra']['title_display']) {
    case 'inline':
    case 'before':
    case 'invisible':
      $output .= ' ' . theme('form_element_label', $variables);
      $output .= ' ' . $prefix . $element['#children'] . $value . $suffix . "\n";
      break;
    case 'after':
      $output .= ' ' . $prefix . $element['#children'] . $value . $suffix;
      $output .= ' ' . theme('form_element_label', $variables) . "\n";
      break;
    case 'none':
    case 'attribute':

      // Output no label and no required marker, only the children.
      $output .= ' ' . $prefix . $element['#children'] . $value . $suffix . "\n";
      break;
  }
  if (!empty($element['#description'])) {
    $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
  }
  $output .= "</div>\n";
  return $output;
}