EntityDisplayFormBase::multistepSubmit

public EntityDisplayFormBase::multistepSubmit($form, FormStateInterface $form_state)

Form submission handler for multistep buttons.

File

core/modules/field_ui/src/Form/EntityDisplayFormBase.php, line 594

Class

EntityDisplayFormBase
Base class for EntityDisplay edit forms.

Namespace

Drupal\field_ui\Form

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public function multistepSubmit($form, FormStateInterface $form_state) {
  $trigger = $form_state->getTriggeringElement();
  $op = $trigger['#op'];
 
  switch ($op) {
    case 'edit':
      // Store the field whose settings are currently being edited.
      $field_name = $trigger['#field_name'];
      $form_state->set('plugin_settings_edit', $field_name);
      break;
 
    case 'update':
      // Set the field back to 'non edit' mode, and update $this->entity with
      // the new settings fro the next rebuild.
      $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);
      break;
 
    case 'cancel':
      // Set the field back to 'non edit' mode.
      $form_state->set('plugin_settings_edit', NULL);
      break;
 
    case 'refresh_table':
      // If the currently edited field is one of the rows to be refreshed, set
      // it back to 'non edit' mode.
      $updated_rows = explode(' ', $form_state->getValue('refresh_rows'));
      $plugin_settings_edit = $form_state->get('plugin_settings_edit');
      if ($plugin_settings_edit && in_array($plugin_settings_edit, $updated_rows)) {
        $form_state->set('plugin_settings_edit', NULL);
      }
      break;
  }
 
  $form_state->setRebuild();
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.