Skip to content

Commit

Permalink
Merge pull request #104 from openeuropa/OPENEUROPA-3149-3
Browse files Browse the repository at this point in the history
OPENEUROPA-3149: Do not add states on content element as they don't play nicely with editors.
  • Loading branch information
ademarco authored Apr 29, 2020
2 parents 2c81b82 + 6555586 commit aec7754
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions modules/oe_paragraphs_timeline/oe_paragraphs_timeline.module
Original file line number Diff line number Diff line change
Expand Up @@ -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],
];
Expand Down

0 comments on commit aec7754

Please sign in to comment.