Issue #3115978: After enabling Require Summary on a field I can’t create a new entity or disable Require Summary.
3 unresolved threads
Merge request reports
Activity
added 2506 commits
-
44a1bff1...5e8d5e8a - 2506 commits from branch
project:11.x
-
44a1bff1...5e8d5e8a - 2506 commits from branch
added 1 commit
- Resolved by Lee Rowlands
added 256 commits
-
f1169a8e...d91d8d0a - 253 commits from branch
project:11.x
- 6d65fa43 - Issue #3115978 by smustgrave, kndr, snehalgaikwad, anmolgoyal74,...
- 5e1dcb5c - Update states
- 71c39c01 - Revert back to before.
Toggle commit list-
f1169a8e...d91d8d0a - 253 commits from branch
added 1 commit
- 58715bf6 - 3115978 - removed duplicated Unchecked conditional.
added 1 commit
- eadce4ca - Use default OR conditional instead of AND conditional.
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
-
eadce4ca...4ca4dbaa - 40 commits from branch
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 ], 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
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
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'); - Comment on lines -76 to +76
changed this line in version 12 of the diff
Please register or sign in to reply