public function NestedEntityTestForm::submitForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php \Drupal\field_test\Form\NestedEntityTestForm::submitForm()
- 10 core/modules/field/tests/modules/field_test/src/Form/NestedEntityTestForm.php \Drupal\field_test\Form\NestedEntityTestForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
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\FormCode
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(),
  ]));
}