I want to alter a form to make the revision log be required. with drupal 8, I am adding this in a module

$form['revision_information']['#required'] = TRUE;

but the field does not become required. What am I missing?

  • Is this structure accurate?
    – Kevin
    Commented Feb 22, 2017 at 17:26
  • I think it is , if I do a print_r I can see it.
    – Diana
    Commented Feb 22, 2017 at 17:29
  • 2
    I believe there was a similar question this month and if there is an attached widget, it also needs to be set as required.... can you post the form item in the question.
    – Kevin
    Commented Feb 22, 2017 at 17:36
  • hi Kevin, is what I put in the question what you wanted?
    – Diana
    Commented Feb 22, 2017 at 18:00
  • 1
    It looks like this is just a details type, not an input
    – Kevin
    Commented Feb 22, 2017 at 18:01

3 Answers 3


this was the answer:

$form ['revision_log']['widget'][0]['value']['#required']=TRUE;

thanks for the tip about the widget Kevin


I know this is an old case but wanted to share (for those new comers) my experience on how I managed to nail the issue in D7 for the above case.

Sol: $form['FIELD_NAME'][LANGUAGE_NONE][0]['value']['#required'] = TRUE;

Note: Remember to replace the "FIELD_NAME" part with your referring field.



Generally to make a field required on form alter what you need is

$form['FIELD_MACHINE_NAME']['#required'] = TRUE;

In your case it didn't work because it's not the nested field and it's a group


$form ['revision_log']['#required'] = TRUE; 

if you want to make the email field required, the following snippet works

$form['account']['mail']['#required'] = TRUE; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.