function field_group_pre_render_bootstrap_grid_col in Bootstrap fieldgroup 7
Implements field_group_pre_render_<format-type>. Format type: Bootstrap Grid Column.
Parameters
$element The field group form element.:
$group The Field group object prepared for pre_render.:
$form The root element or form.:
File
- ./
bootstrap_fieldgroup.module, line 559 - Module file for the bootstrap_fieldgroup module.
Code
function field_group_pre_render_bootstrap_grid_col(&$element, $group, &$form) {
// Get the textual format of the the options available (xs, sm, md, lg).
$screen_size_texts = _bootstrap_grid_col_screens();
$settings = $group->format_settings['instance_settings'];
// Add only the classes defined in the field group configuration. The rest
// will be omitted.
$col_classes = '';
foreach ($screen_size_texts as $screen_size => $text) {
if (!empty($settings['bootstrap_grid_col_' . $screen_size])) {
$col_classes .= 'col-' . $screen_size . '-' . $settings['bootstrap_grid_col_' . $screen_size] . ' ';
}
}
$prefix = '<div class="' . $col_classes . $group->classes . '">';
$suffix = '</div>';
// Wrap the fields in a panel if the panelize option is set to 1.
if ($settings['panelize']) {
$prefix .= '<div class="panel panel-default"><div class="panel-body">';
$suffix .= '</div></div>';
}
$element += array(
'#type' => 'markup',
'#prefix' => $prefix,
'#suffix' => $suffix,
);
}