Skip to content
Snippets Groups Projects
Commit 18efe8ef authored by Lily Yan's avatar Lily Yan
Browse files

ISTWCMS-7182 Remove validation of quote text field in...

ISTWCMS-7182 Remove validation of quote text field in UwCblBlockquoteEventSubscriber.php due to this field is set to required in UI
parent 9e8131d4
No related branches found
No related tags found
1 merge request!255ISTWCMS-7182 Blockquote block quote text field should show it is required
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
namespace Drupal\uw_custom_blocks\EventSubscriber; namespace Drupal\uw_custom_blocks\EventSubscriber;
use Drupal\Core\Form\FormStateInterface;
use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\core_event_dispatcher\FormHookEvents;
use Drupal\preprocess_event_dispatcher\Event\BlockPreprocessEvent; use Drupal\preprocess_event_dispatcher\Event\BlockPreprocessEvent;
use Drupal\uw_custom_blocks\CustomBlocks\UwCblBase; use Drupal\uw_custom_blocks\CustomBlocks\UwCblBase;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
...@@ -14,53 +11,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; ...@@ -14,53 +11,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/ */
class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscriberInterface { class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscriberInterface {
/**
* Alter form.
*
* @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event
* The event.
*/
public function alterForm(FormAlterEvent $event): void {
if ($this->checkLayoutBuilder($event, 'Blockquote')) {
// Get the form from the event.
$form = &$event->getForm();
// Add the validation for blockquote.
$form['#validate'][] = [$this, 'validateBlockquote'];
}
}
/**
* Form validation for blockquote.
*
* @param array $form
* The complete form structure.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
*/
public function validateBlockquote(array &$form, FormStateInterface $form_state) {
// Get the settings from the form.
$settings = $form_state->getValue('settings', NULL);
// If there are settings, continue to process.
if ($settings) {
// If there is a block, continue to process.
if ($block = $settings['block_form']) {
// If there is no text in the quote text, set error.
if ($block['field_uw_bq_quote_text'][0]['value'] == '') {
// Set the form error for not having any quote text.
$form_state->setErrorByName('settings][block_form][field_uw_bq_quote_text', 'You must enter quote text.');
}
}
}
}
/** /**
* Preprocess blocks with blockquote and set variables. * Preprocess blocks with blockquote and set variables.
* *
...@@ -104,7 +54,6 @@ class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscribe ...@@ -104,7 +54,6 @@ class UwCblBlockquoteEventSubscriber extends UwCblBase implements EventSubscribe
*/ */
public static function getSubscribedEvents() { public static function getSubscribedEvents() {
return [ return [
FormHookEvents::FORM_ALTER => 'alterForm',
BlockPreprocessEvent::name() => 'preprocessBlock', BlockPreprocessEvent::name() => 'preprocessBlock',
]; ];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment