You are here

function _hosting_site_field in Hosting 7.4

Same name and namespace in other branches
  1. 6.2 site/hosting_site.form.inc \_hosting_site_field()
  2. 7.3 site/hosting_site.form.inc \_hosting_site_field()

Helper function to generate form elements for the site form.

3 calls to _hosting_site_field()
hosting_client_form_site_node_form_alter in client/hosting_client.module
Implements hook_form_FORM_ID_alter().
hosting_site_form in site/hosting_site.form.inc
Implements hook_form().
hosting_ssl_site_form in web_server/ssl/hosting_ssl.nodeapi.inc
Form API code to extend the site form with SSL fields.

File

site/hosting_site.form.inc, line 10
Site node form.

Code

function _hosting_site_field(&$form, $node, $item, $element, $filter_display = 'filter_xss', $editable = FALSE, $show_desc = TRUE) {
  $css_id = str_replace("_", "-", $item);
  $type = $element['#type'];
  if (!isset($node->nid) || $editable) {

    // Create it.
    if ($element['#type'] == 'radios' && !count($element['#options'])) {
      $form[$item] = array(
        '#type' => 'value',
        '#value' => !empty($element['#default_value']) ? $element['#default_value'] : NULL,
      );
    }
    else {
      $form[$item] = $element;
    }
    if ($show_desc) {

      // The text to display when there are no valid options to select.
      $form[$item . '_description'] = array(
        '#prefix' => "<div class='hosting-site-field-description' id='hosting-site-field-{$css_id}-description'>",
        '#suffix' => '</div>',
        '#type' => 'item',
        '#title' => $element['#title'],
        '#description' => isset($element['#description']) ? $element['#description'] : NULL,
        '#markup' => "<div class='placeholder'>" . $filter_display($element['#default_value']) . "</div>",
      );
      if (isset($element['#weight'])) {
        $form[$item . '_description']['#weight'] = $element['#weight'];
      }
    }
  }
  else {
    $type = 'display';
    if ($show_desc) {

      // Display it.
      $form['info'][$item] = array(
        '#type' => 'item',
        '#title' => $element['#title'],
        '#markup' => $filter_display($element['#default_value']),
        '#required' => FALSE,
      );
      if (isset($element['#weight'])) {
        $form['info'][$item]['#weight'] = $element['#weight'];
      }
    }
    $form[$item] = array(
      '#type' => 'hidden',
      '#value' => $element['#default_value'],
    );
  }
  $form[$item]['#hosting_site_field'] = $item;
  $form[$item]['#hosting_site_field_value'] = $element['#default_value'];
  $form[$item]['#prefix'] = "<div class='hosting-site-field hosting-site-field-{$type}' id='hosting-site-field-{$css_id}'>";
  $form[$item]['#suffix'] = "</div>";
}