You are here

function ds_forms_form_alter in Display Suite 7.2

Same name and namespace in other branches
  1. 7 modules/ds_forms/ds_forms.module \ds_forms_form_alter()

Implements hook_form_alter().

File

modules/ds_forms/ds_forms.module, line 75
Display Suite forms integration.

Code

function ds_forms_form_alter(&$form, &$form_state, $form_id) {
  if ($ds_form = ds_build_load($form, $form_id)) {
    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.
      $form['#theme'] = array(
        'ds_forms_custom_form',
      );
      $class = strtr($layout['layout'], '_', '-');
      if (isset($form['#attributes']['class']) && is_array($form['#attributes']['class']) || !isset($form['#attributes']['class'])) {
        $form['#attributes']['class'][] = $class;
      }
      elseif (isset($form['#attributes']['class']) && is_string($form['#attributes']['class'])) {
        $form['#attributes']['class'] .= ' ' . $class . ' ';
      }
    }
  }
}