You are here

function socialbase_form_node_form_alter in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  2. 8 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  3. 8.2 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  4. 8.3 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  5. 8.4 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  6. 8.5 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  7. 8.6 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()
  8. 8.7 themes/socialbase/includes/form.inc \socialbase_form_node_form_alter()

Implements hook_form_BASE_ID_alter().

Set button types for input elements. Note that these variables are read in hook_preprocess_input.

File

themes/socialbase/includes/form.inc, line 447
The form inc file for the Social base theme.

Code

function socialbase_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['#attributes']['class'][] = 'form--default';

  // Delete is not an input element, so we must apply extra classes
  // to anchor directly.
  $button_size = theme_get_setting('button_size');
  if (isset($form['actions']['delete'])) {
    $form['actions']['delete']['#attributes']['class'][] = 'btn btn-flat';
    if ($button_size === 'btn-xs') {
      $form['actions']['delete']['#attributes']['class'][] = 'btn-xs';
    }
    elseif ($button_size === 'btn-sm') {
      $form['actions']['delete']['#attributes']['class'][] = 'btn-sm';
    }
    elseif ($button_size === 'btn-lg') {
      $form['actions']['delete']['#attributes']['class'][] = 'btn-lg';
    }
  }

  // Unlock is not an input element, so we must apply extra classes
  // to anchor directly.
  if (isset($form['actions']['unlock'])) {
    $form['actions']['unlock']['#attributes']['class'][] = 'btn';
    $form['actions']['unlock']['#attributes']['class'][] = 'btn-flat';
  }
  if (isset($form['actions']['preview'])) {
    $form['actions']['preview']['#button_type'] = 'flat';
  }
  if (isset($form['actions']['submit'])) {
    $form['actions']['submit']['#button_level'] = 'raised';
    $form['actions']['submit']['#button_type'] = 'primary';
  }
  if (isset($form['actions']['publish'])) {
    $form['actions']['publish']['#button_level'] = 'raised';
    $form['actions']['publish']['#button_type'] = 'primary';
  }
  if (isset($form['actions']['unpublish'])) {
    $form['actions']['unpublish']['#button_level'] = 'raised';
    $form['actions']['unpublish']['#button_type'] = 'primary';
  }
}