The FormStateInterface in PHP Drupal.core.form is a library that allows developers to access and manipulate the data that is being transmitted between the Drupal form and the server. The FormStateInterface contains a variety of methods that can be used to retrieve, modify and validate form data, as well as to identify the current state of the form.
Example 1:
To access the values submitted from a form, you can use the getValue() method:
$form_state->getValue('field_name');
This will return the value of the 'field_name' field that was submitted with the form.
Example 2:
To validate a submitted form, you can use the triggerValidation() method:
$form_state->triggerValidation();
This will cause Drupal to validate all fields in the form and return any errors that are encountered.
Example 3:
To set the value of a form field, you can use the setValue() method:
$form_state->setValue('field_name', 'new_value');
This will set the value of the 'field_name' field to 'new_value'.
Package library: Drupal core.
PHP Drupal\Core\Form FormStateInterface::has - 30 examples found. These are the top rated real world PHP examples of Drupal\Core\Form\FormStateInterface::has extracted from open source projects. You can rate examples to help us improve the quality of examples.