You are here

function webform_layout_box_prerender in Webform Layout 7.2

Same name and namespace in other branches
  1. 6 layout_box.inc \webform_layout_box_prerender()
  2. 7 layout_box.inc \webform_layout_box_prerender()

Pre-render function to set a layout_box ID and classes.

1 string reference to 'webform_layout_box_prerender'
_webform_render_layout_box in ./layout_box.inc
Implements _webform_render_component().

File

./layout_box.inc, line 76
Webform module layout_box component.

Code

function webform_layout_box_prerender($element) {
  $attributes = empty($element['#attributes']) ? array(
    'class' => array(),
  ) : $element['#attributes'];
  $attributes['class'][] = 'webform-layout-box';
  $attributes['class'][] = $element['#webform_component']['extra']['align'];
  $attributes['class'][] = 'webform-component--' . str_replace('_', '-', implode('--', array_slice($element['#parents'], 1)));

  // css class for number of children
  $n = empty($element['#webform_component']['children']) ? 0 : count($element['#webform_component']['children']);
  if ($element['#webform_component']['extra']['align'] == 'equal' && $n > 1) {
    $attributes['class'][] = 'child-width-' . $n;
  }
  $element['#prefix'] = '<div ' . drupal_attributes($attributes) . '>';
  return $element;
}