public function LayoutBuilderUpdateBlockForm::validateForm in Panopoly Magic 8.2
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 ConfigureBlockFormBase::validateForm
File
- src/
Form/ LayoutBuilderUpdateBlockForm.php, line 58
Class
- LayoutBuilderUpdateBlockForm
- Enhances the update block form with live preview.
Namespace
Drupal\panopoly_magic\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Suppress form validation errors when Preview is clicked, allowing partial
// previews and removing error messages when a block has multiple required
// fields.
// Supporess form validation errors when Cancel is clicked, allowing the
// dialog to be dismissed discarding changes if there are validation errors.
$submit_button_name = end($form_state
->getTriggeringElement()['#parents']);
if ($submit_button_name == 'preview' || $submit_button_name == 'cancel') {
// Suppress all future validation errors from parent::validateForm().
$form_state
->setLimitValidationErrors([]);
// Clear any existing validation errors from the Field API.
$form_state
->clearErrors();
}
parent::validateForm($form, $form_state);
}