public function PageVariantAddForm::validateForm in Page Manager 8
Same name and namespace in other branches
- 8.4 page_manager_ui/src/Form/PageVariantAddForm.php \Drupal\page_manager_ui\Form\PageVariantAddForm::validateForm()
Form validation 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 FormBase::validateForm
File
- page_manager_ui/
src/ Form/ PageVariantAddForm.php, line 124 - Contains Drupal\page_manager_ui\Form\PageVariantAddForm.
Class
- PageVariantAddForm
- Provides a form for adding a variant.
Namespace
Drupal\page_manager_ui\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// If the label is not present or is an empty string.
if (!$form_state
->hasValue('label') || !$form_state
->getValue('label')) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/** @var $page_variant \Drupal\page_manager\Entity\PageVariant */
$page_variant = $cached_values['page_variant'];
$plugin = $page_variant
->getVariantPlugin();
/** @var \Drupal\Core\StringTranslation\TranslatableMarkup $admin_label */
$admin_label = $plugin
->getPluginDefinition()['admin_label'];
$form_state
->setValue('label', (string) $admin_label);
}
// Currently the parent does nothing, but that could change.
parent::validateForm($form, $form_state);
}