6

Trying to figure out how to hide revision information from node form. When users create a node, they see revision info at the bottom which confuses them. I can't seem to disable revision info from the content type edit settings since there are nodes already. So the only solution is to hide it.

The way that I am going is by trying to add this:

$form['revision_information']['#access'] = false;

My question is how can I add that to my theme-name.theme file?

The content type is QUESTIONS

4
  • If the theme you are talking about is the admin theme, you can add it in that file with hook_form_alter.
    – Kevin
    Oct 3, 2018 at 17:46
  • No it is not the admin theme.
    – Progonat
    Oct 3, 2018 at 17:49
  • If the node creating/editing is under the admin theme, then adding it in any other theme file won't have an effect. If the theme you are editing is the one used by this, then you can add it to the .theme file with hook_form_alter.
    – Kevin
    Oct 3, 2018 at 17:52
  • It is a custom bootstrap theme. Adding that line directly to the mytheme.theme file made no difference. Can form altered via mytheme.theme file or does it have to be with a custom module?
    – Progonat
    Oct 3, 2018 at 19:42

4 Answers 4

10

Please try below code in your theme-name.theme file.

/**
 * Implements hook_form_alter().
 */
function THEMENAME_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['revision_information']['#access'] = FALSE;
}
0
2

There also is the Hide Revision Field module which makes the revision info another field you can disable in the form mode of an entity. It also gives you some more options, like permission based display etc.

Hide Revision Field provides a configurable field formatter for the revision log field for revisionable entities. This allows you to create revisions but reduces noise for your content editors/site owners. All revisionable entity types are supported including module added.

1

When you create a new content type you have the option to not create new revisions. Whilst you can set that for future content any existing nodes will still have revisions on. If there are not too many to change you could manually uncheck this or write a script in the database to uncheck them.

0

Try hiding it using css:

.field--name-revision-log-message {
  display: none;
}

I used this for media.

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.