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

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
2016-10-29 09:05:25
Comments
Leave a Comment

Please login to continue.