public function DimensionsTestForm::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/ DimensionsTestForm.php, line 48
Class
Namespace
Drupal\physical_test\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Create Length objects to ensure the values are valid.
$value = $form_state
->getValue('dimensions');
$length = new Length($value['length'], $value['unit']);
$width = new Length($value['width'], $value['unit']);
$height = new Length($value['height'], $value['unit']);
$this
->messenger()
->addStatus($this
->t('Length: "@length", width: "@width", height: "@height", unit: "@unit".', [
'@length' => $length
->getNumber(),
'@width' => $width
->getNumber(),
'@height' => $height
->getNumber(),
'@unit' => $height
->getUnit(),
]));
}