Skip to content

Commit

Permalink
adding form alter
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Nov 14, 2024
1 parent c4383b0 commit 6fa1853
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Plugin/FormAlter/SolrReloadFormAlter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Drupal\search_api_pantheon\Plugin\FormAlter;

/**
* Class SolrReloadFormAlter.
*
* @FormAlter(
* id = "search_api_pantheon_reload_form_alter",
* label = @Translation("Alter the reload form for the pantheon environment."),
* form_id = {
* "solr_reload_core_form"
* },
* )
*
* @package Drupal\search_api_pantheon\Plugin\FormAlter
*/
class SolrReloadFormAlter extends FormAlterBase {

/**
* {@inheritdoc}
*/
public function formAlter(array &$form, FormStateInterface $form_state, $form_id) {
// do something here, for example add submit handler.
print_r($form_state->getValues());
$submit_handler = __CLASS__ . '::formSubmit';
array_unshift($form['actions']['submit']['#submit'], $submit_handler);
}

/**
* Custom form submit.
*/
public static function formSubmit($form, FormStateInterface $form_state) {
print_r($form_state->getValues());
exit(1);
}

}

0 comments on commit 6fa1853

Please sign in to comment.