function NestedEntityTestForm::submitForm

Same name in other branches
  1. 8.9.x core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php \Drupal\field_test\Form\NestedEntityTestForm::submitForm()
  2. 10 core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php \Drupal\field_test\Form\NestedEntityTestForm::submitForm()
  3. 11.x core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php \Drupal\field_test\Form\NestedEntityTestForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php, line 97

Class

NestedEntityTestForm
Provides a form for field_test routes.

Namespace

Drupal\field_test\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    
    /** @var \Drupal\Core\Entity\EntityInterface $entity_1 */
    $entity_1 = $form_state->get('entity_1');
    $entity_1->save();
    
    /** @var \Drupal\Core\Entity\EntityInterface $entity_2 */
    $entity_2 = $form_state->get('entity_2');
    $entity_2->save();
    $this->messenger()
        ->addStatus($this->t('test_entities @id_1 and @id_2 have been updated.', [
        '@id_1' => $entity_1->id(),
        '@id_2' => $entity_2->id(),
    ]));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.