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, DrupalCoreFormFormStateInterface $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 ?