0

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

Thank you.

  • 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 '18 at 17:46
  • No it is not the admin theme. – Progonat Oct 3 '18 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 '18 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 '18 at 19:42
2

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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