You are here

public function FieldConfigCloneForm::submitForm in Field tools 8

Form submission handler for the 'clone' action.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: A reference to a keyed array containing the current state of the form.

Overrides EntityForm::submitForm

File

src/Form/FieldConfigCloneForm.php, line 145

Class

FieldConfigCloneForm
Provides a form for cloning a field.

Namespace

Drupal\field_tools\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $destinations = array_filter($form_state
    ->getValue('destinations'));
  foreach ($destinations as $destination) {
    list($destination_entity_type, $destination_bundle) = explode('::', $destination);
    $this->fieldCloner
      ->cloneField($this->entity, $destination_entity_type, $destination_bundle);
  }
  $this
    ->messenger()
    ->addMessage($this
    ->t("The field has been cloned."));

  // TODO: redirect
}