function _hosting_site_field in Hosting 6.2
Same name and namespace in other branches
- 7.4 site/hosting_site.form.inc \_hosting_site_field()
- 7.3 site/hosting_site.form.inc \_hosting_site_field()
Helper function to generate form elements for the site form.
2 calls to _hosting_site_field()
- hosting_site_form in site/
hosting_site.form.inc - Implements hook_form().
- hosting_ssl_site_form in web_server/
ssl/ hosting_ssl.nodeapi.inc
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 (!$node->nid || $editable) {
// create it
if ($element['#type'] == 'radios' && !sizeof($element['#options'])) {
$form[$item] = array(
'#type' => 'hidden',
'#value' => key($element['#options']),
);
}
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' => $element['#description'],
'#value' => "<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'],
'#value' => $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>";
}