You are here

function cms_content_sync_draggableviews_form_alter in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 modules/cms_content_sync_draggableviews/cms_content_sync_draggableviews.module \cms_content_sync_draggableviews_form_alter()
  2. 2.1.x modules/cms_content_sync_draggableviews/cms_content_sync_draggableviews.module \cms_content_sync_draggableviews_form_alter()

Implements hook_form_alter().

File

modules/cms_content_sync_draggableviews/cms_content_sync_draggableviews.module, line 13

Code

function cms_content_sync_draggableviews_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Filter the right form.
  if (strpos($form_id, 'views_form_') === FALSE) {
    return;
  }
  if (empty($form['actions']['save_order'])) {
    return;
  }

  // If there is no results remove the save-order button.
  if (!isset($form['draggableviews'][0])) {
    return;
  }
  $form['actions']['save_order_and_push'] = $form['actions']['save_order'];
  $form['actions']['save_order_and_push']['#value'] = Drupal::translation()
    ->translate('Save order and push');
  $form['actions']['save_order_and_push']['#submit'][] = 'cms_content_sync_draggableviews_views_submit';
}