function ds_forms_field_widget_field_collection_embed_form_alter in Display Suite 7.2
Implements hook_field_widget_WIDGET_TYPE_form_alter().
File
- modules/
ds_forms/ ds_forms.module, line 94 - Display Suite forms integration.
Code
function ds_forms_field_widget_field_collection_embed_form_alter(&$element, &$form_state, $context) {
if ($ds_form = ds_build_load($element, 'field_collection_embed')) {
if ($layout = ds_get_layout($ds_form->entity_type, $ds_form->bundle, 'form', FALSE)) {
// Add the theming function and add the layout as a class.
$element['#theme'] = array(
'ds_forms_custom_form',
);
$element['#form_id'] = 'field_collection_embed';
$class = strtr($layout['layout'], '_', '-');
if (isset($element['#attributes']['class']) && is_array($element['#attributes']['class']) || !isset($element['#attributes']['class'])) {
$element['#attributes']['class'][] = $class;
}
elseif (isset($element['#attributes']['class']) && is_string($element['#attributes']['class'])) {
$element['#attributes']['class'] .= ' ' . $class . ' ';
}
}
}
}