From 6555586f439f75069b1b082b39da5b7856c14f29 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 29 Apr 2020 15:46:46 +0200 Subject: [PATCH] OPENEUROPA-3149: Do not add states on content element as they don't play nicely with editors. --- .../oe_paragraphs_timeline.module | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/oe_paragraphs_timeline/oe_paragraphs_timeline.module b/modules/oe_paragraphs_timeline/oe_paragraphs_timeline.module index 001e233a..1f2b734d 100644 --- a/modules/oe_paragraphs_timeline/oe_paragraphs_timeline.module +++ b/modules/oe_paragraphs_timeline/oe_paragraphs_timeline.module @@ -48,18 +48,13 @@ function oe_paragraphs_timeline_field_widget_timeline_widget_form_alter(&$elemen $selector .= '[' . implode('][', $parents) . ']'; } - // Mark label as required when title or content are filled in. - $element['label']['#states']['required'][] = [ - 'textarea[name="' . $selector . '[body][value]"]' => ['filled' => TRUE], - ]; + // Mark label as required when title is filled in and vice-versa. + // The content element can have an editor assigned, and states do not play + // nicely with it, so we don't show any visual hint and rely only on + // server-side validation. $element['label']['#states']['required'][] = [ ':input[name="' . $selector . '[title]"]' => ['filled' => TRUE], ]; - - // Mark title as required when label or content are filled in. - $element['title']['#states']['required'][] = [ - 'textarea[name="' . $selector . '[body][value]"]' => ['filled' => TRUE], - ]; $element['title']['#states']['required'][] = [ ':input[name="' . $selector . '[label]"]' => ['filled' => TRUE], ];