I would like to set the file description as required. I tried it with this code:
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if ($form_id == 'node_news_homepage_edit_form') {
$form['field_downloads']['widget'][0]['description_field']['#required'] = TRUE;
}
}
But it didn't work. Could anyone help me?
description_field
looks odd to me, did you check it exists in $form? Should bedescription
, if it is named after the File field property and this is the field type the question is about.