Skip to content
Snippets Groups Projects

Added element_validate() function to remove keys from the form state that are...

2 files
+ 58
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -419,9 +419,29 @@ class FilterMarkdown extends FilterBase implements ContainerFactoryPluginInterfa
$parserElement['id']['#description'] = $this->moreInfo($parserElement['id']['#description'], $url);
}
// The filter module expects that every form element is a configuration key.
// Add a validation function to remove values from the form state that
// should not be saved as configuration.
$element['#element_validate'][] = [$this, 'subformValidate'];
return $element;
}
/**
* Removes certain keys from the markdown settings.
*
* @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_settings = &$form_state->getValue(['filters', 'markdown', 'settings']);
unset($markdown_settings['vertical_tabs']);
unset($markdown_settings['error']);
}
/**
* The AJAX callback used to return the parser ajax wrapper.
*/
Loading