Skip to content
Snippets Groups Projects

Issue #3115978: After enabling Require Summary on a field I can’t create a new entity or disable Require Summary.

Issue #3115978: After enabling Require Summary on a field I can’t create a new entity or disable Require Summary.
3 unresolved threads
3 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Stephen Mustgrave added 256 commits

    added 256 commits

    Compare with previous version

  • Lee Rowlands resolved all threads

    resolved all threads

  • Lee Rowlands added 1 commit

    added 1 commit

    • 5de6f3f7 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Sara Cartee-Kennedy added 113 commits

    added 113 commits

    Compare with previous version

  • added 1 commit

    • a3a74c5e - 3115978 updated conditionals.

    Compare with previous version

  • added 1 commit

    • 58715bf6 - 3115978 - removed duplicated Unchecked conditional.

    Compare with previous version

  • added 1 commit

    • eadce4ca - Use default OR conditional instead of AND conditional.

    Compare with previous version

  • Stephen Mustgrave added 42 commits

    added 42 commits

    • eadce4ca...4ca4dbaa - 40 commits from branch project:11.x
    • 6e72d034 - Merge branch '11.x' of git.drupal.org:project/drupal into 3115978-required-summary-bug
    • c32c8171 - Remove condition

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 107 107 '#type' => 'checkbox',
    108 108 '#title' => $this->t('Require summary'),
    109 '#description' => $this->t('The summary will also be visible when marked as required.'),
    109 '#description' => $this->t('Enable "Summary input" and "Require summary" to make the summary required.'),
    110 '#element_validate' => [[static::class, 'validateRequiredSummary']],
    110 111 '#default_value' => $settings['required_summary'],
    112 '#states' => [
    113 'visible' => [
    114 ':input[name="settings[display_summary]"]' => ['checked' => TRUE],
    115 ],
    116 'enabled' => [
    117 ':input[name="settings[display_summary]"]' => ['checked' => TRUE],
    118 ],
    119 'unchecked' => [
    120 ':input[name="settings[required_summary]"]' => ['checked' => FALSE],
    121 ],
    • Is this correct? I think this should be on the display_summary element and say to uncheck the required_summary when you uncheck the display_summary.

    • I'm not sure if it's "correct" but it's intentional. I added the condition based on a very old example in 2477053 that seemed to be the same as my issue. The Require Summary field is set to unchecked if it's not checked so that it's correct on page load. It feels a bit dirty, but I thought a better fix would be out of scope for this issue.

      Edited by Sara Cartee-Kennedy
    • Please register or sign in to reply
  • 131 * This function is assigned as an #element_validate callback in
    132 * fieldSettingsForm().
    133 */
    134 public static function validateRequiredSummary($element, FormStateInterface $form_state) {
    135 if (!empty($element['#value']) && empty($form_state->getValue(['settings', 'display_summary']))) {
    136 $form_state->setError($element, t('If "Require summary" is checked "Summary input" has to be checked as well.'));
    137 }
    138 }
    139
    116 140 /**
    117 141 * {@inheritdoc}
    118 142 */
    119 143 public function getConstraints() {
    120 144 $constraints = parent::getConstraints();
    121 if ($this->getSetting('required_summary')) {
    145 if ($this->getSetting('required_summary') && $this->getSetting('display_summary')) {
    • Comment on lines -121 to +145

      I think we should be added a constraint here that required_summary can only be true if display summary is true.

      Also I think we need to update existing fields that have required_summary set to true and display_summary set to false to be valid.

    • Please register or sign in to reply
  • 73 73 $element = parent::formElement($items, $delta, $element, $form, $form_state);
    74 74
    75 75 $display_summary = $items[$delta]->summary || $this->getFieldSetting('display_summary');
    76 $required = empty($form['#type']) && $this->getFieldSetting('required_summary');
    76 $required = $display_summary && !$form_state->has('default_value_widget') && $this->getFieldSetting('required_summary');
  • added 1 commit

    • 855852bc - Reverted changed to $required.

    Compare with previous version

  • Please register or sign in to reply
    Loading