You are here

function opigno_catalog_form_views_exposed_form_alter in Opigno training catalog 3.x

Implements hook_form_FORM_ID_alter().

File

./opigno_catalog.module, line 119
Contains opigno_catalog.module.

Code

function opigno_catalog_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $id = $form['#id'] ?? '';
  if ($id !== 'views-exposed-form-opigno-training-catalog-training-catalogue') {
    return;
  }
  $form['search']['#size'] = 0;

  // Add classes to action buttons, change their order.
  $form['actions']['submit']['#weight'] = 15;
  $form['actions']['submit']['#attributes'] = [
    'class' => [
      'btn',
      'btn-bg',
      'btn-rounded',
      'apply-catalog-filters',
    ],
  ];
  $form['actions']['reset']['#access'] = TRUE;
  $form['actions']['reset']['#attributes'] = [
    'class' => [
      'btn',
      'btn-rounded',
      'btn-reset-filter',
    ],
  ];

  // Add one more submit button to display at the top of the form.
  $form['actions']['search_submit'] = [
    '#type' => 'submit',
    '#value' => t('Search'),
    '#attributes' => [
      'class' => [
        'opigno-filters-submit',
      ],
    ],
  ];

  // Add cache tags.
  $form['#cache']['tags'][] = 'group_list';
  $form['#cache']['tags'][] = 'taxonomy_term_list';
}