Skip to content
Snippets Groups Projects
Commit a796b217 authored by Zoltan Horvath's avatar Zoltan Horvath Committed by Diogo Vargas
Browse files

ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent...

ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent them being called in the main form's context
parent 12303b0b
No related branches found
No related tags found
2 merge requests!214ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent...,!212Release 2.3.0
......@@ -6,6 +6,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\Attribute\FieldWidget;
use Drupal\Core\Field\FieldDefinitionInterface;
......@@ -176,9 +177,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#type' => 'submit',
'#value' => $this->t('Refresh'),
'#op' => 'refresh_table',
'#submit' => ['::multistepSubmit'],
'#submit' => [[get_class($this), 'multistepSubmit']],
'#ajax' => [
'callback' => '::multistepAjax',
'callback' => get_class($this) . '::multistepAjax',
'wrapper' => 'field-display-overview-wrapper',
'effect' => 'fade',
// The button stays hidden, so we hide the Ajax spinner too. Ad-hoc
......@@ -187,7 +188,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
],
'#attributes' => [
'class' => [
'visually-hidden',
'js-hide',
'row-refresher',
],
],
......@@ -267,7 +268,7 @@ public static function getRowRegion(array $row): ?string {
/**
* Form submission handler for multistep buttons.
*/
public function multistepSubmit($form, FormStateInterface $form_state): void {
public static function multistepSubmit($form, FormStateInterface $form_state): void {
$trigger = $form_state->getTriggeringElement();
$op = $trigger['#op'];
......@@ -284,7 +285,10 @@ public function multistepSubmit($form, FormStateInterface $form_state): void {
$field_name = $trigger['#field_name'];
$form_state->set('plugin_settings_edit', NULL);
$form_state->set('plugin_settings_update', $field_name);
$this->entity = $this->buildEntity($form, $form_state);
$form_object = $form_state->getFormObject();
if ($form_object instanceof EntityFormInterface) {
$form_object->setEntity($form_object->buildEntity($form, $form_state));
}
break;
case 'cancel':
......@@ -308,7 +312,7 @@ public function multistepSubmit($form, FormStateInterface $form_state): void {
/**
* Ajax handler for multistep buttons.
*/
public function multistepAjax($form, FormStateInterface $form_state): array {
public static function multistepAjax($form, FormStateInterface $form_state): array {
$trigger = $form_state->getTriggeringElement();
$op = $trigger['#op'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment