public function MeasurementTestForm::submitForm in Physical Fields 8
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
- tests/
modules/ physical_test/ src/ Form/ MeasurementTestForm.php, line 44
Class
Namespace
Drupal\physical_test\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Create a Length object to ensure the values are valid.
$value = $form_state
->getValue('height');
$height = new Length($value['number'], $value['unit']);
$this
->messenger()
->addStatus($this
->t('The number is "@number" and the unit is "@unit".', [
'@number' => $height
->getNumber(),
'@unit' => $height
->getUnit(),
]));
}