Skip to content
Snippets Groups Projects

Resolve #3463119 "Abort validation"

4 files
+ 79
1
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -419,9 +419,33 @@ class FilterMarkdown extends FilterBase implements ContainerFactoryPluginInterfa
$parserElement['id']['#description'] = $this->moreInfo($parserElement['id']['#description'], $url);
}
// When the markdown filter is not enabled, not all required information for
// to validate the settings is available. In this case, clear the settings
// as they are not needed anyway when the markdown filter is disabled.
$element['#element_validate'][] = [$this, 'subformValidate'];
return $element;
}
/**
* Removes the markdown settings when the markdown filter is disabled.
*
* @param array $element
* The element being validated.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*/
public function subformValidate(array $element, FormStateInterface $form_state) {
$markdown = &$form_state->getValue(['filters', 'markdown']);
// Check if markdown is enabled. If it is not, do not attempt to save any
// settings to avoid validation issues.
if (empty($markdown['status'])) {
// Do not save any settings.
unset($markdown['settings']);
}
}
/**
* The AJAX callback used to return the parser ajax wrapper.
*/
Loading