function theme_acquia_lift_personalizable_field_form in Acquia Lift Connector 7
Same name and namespace in other branches
- 7.2 theme/acquia_lift.theme.inc \theme_acquia_lift_personalizable_field_form()
Returns HTML for a personalized form element.
Parameters
$variables: An associative array containing:
- element: A render element representing the form element.
File
- theme/
acquia_lift.theme.inc, line 18 - acquia_lift.theme.inc Provides theme functions for Acquia Lift.
Code
function theme_acquia_lift_personalizable_field_form($variables) {
$element = $variables['element'];
// Sort items according to '_weight' (needed when the form comes back after
// preview or failed validation).
$items = array();
foreach (element_children($element) as $key) {
if ($key === 'add_more') {
$add_more_button =& $element[$key];
// Convert the form-submit to a button so that it is more styleable with // css. If markup changes are still needed by a theme, allow for a more
// specific theme_html_tag__personalize_button() override.
$add_more_button['#theme'] = 'html_tag__personalize_button';
$add_more_button['#tag'] = 'button';
$add_more_button['#attributes']['id'] = $add_more_button['#id'];
$add_more_button['#attributes']['class'][] = 'form-submit';
$add_more_button['#attributes']['class'][] = 'personalize-field-add';
$add_more_button['#attributes']['title'] = t('Add an option');
$add_more_button['#value'] = t('Add an option');
unset($add_more_button['#theme_wrappers']);
}
else {
$element[$key]['_weight']['#theme_wrappers'][] = 'acquia_lift_personalize_field_weight_field_wrapper';
$items[] =& $element[$key];
}
}
usort($items, '_field_sort_items_value_helper');
$rendered_items = '<div class="personalize-field-options">';
foreach ($items as $key => $item) {
$class = 'personalize-field' . ($key == 0 ? ' personalize-field-visible' : '');
$rendered_items .= '<div class="' . $class . '">' . drupal_render($item) . '</div>';
}
$rendered_items .= '</div>';
$children = drupal_render($add_more_button);
$children .= $rendered_items;
$output = '<div class="form-item">';
// If #title is not set, we don't display any label or required marker.
if (!isset($element['#title'])) {
$element['#title_display'] = 'none';
}
$prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#prefix'] . '</span> ' : '';
$suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#suffix'] . '</span>' : '';
switch ($element['#title_display']) {
case 'before':
case 'invisible':
$output .= ' ' . theme('form_element_label', $variables);
$output .= ' ' . $prefix . $children . $suffix . "\n";
break;
case 'after':
$output .= ' ' . $prefix . $children . $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 . $children . $suffix . "\n";
break;
}
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
$output .= '</div>';
return $output;
}