'Remove field depending on display type in Embed entity ckeditor Drupal
I have a specific display for document type entity. We made caption required for other media type but I want it to not be required when I select display as "document link" how can I do ?
For now I have something like this:
function MY_MODULE_form_entity_embed_dialog_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
if (isset($form['attributes']['data-entity-embed-display'] && .....)){
$form['attributes']['data-caption']['#required'] = FALSE;
} else {
$form['attributes']['data-caption']['#required'] = TRUE;
}
The ... is for adding the fact that document link option must be selected bu I don't know how to do it.
Anyone have an idea, please ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
