How can I add a block with some HTML to the Node Add/Edit form? I've tried adding a new #markup field but I couldn't position it where I need by using weight.

See image below for desired location: just below the vertical tabs displayed to the right in the Seven theme.

Node edit form

  • 1
    I suggest posting your code here, so others can have a look and point out if there is anything wrong. Commented Jul 20, 2016 at 19:02

2 Answers 2


If you're looking insert renderable elements into the form array in the same manner as the grouped vertical tabs, you can hook_form_alter() your way to this via adding a details form element:

function MYMODULE_form_alter(&$form, $form_state, $form_id) {

  // @TODO: Add your own logic for filtering relevant node forms
  if (in_array($form_id, array('node_page_form', 'node_page_edit_form'))) {
    $form['example'] = array(
      '#type' => 'details',
      '#title' => t(''),
      '#description' => t(''),
      '#group' => 'advanced',
      '#open' => TRUE,
      'markup' => array(
        '#markup' => '<p>Random Markup</p>',
      '#weight' => 1000,

If you're looking to add markup that's not relevant to your node forms, you might be better off subtheming Seven and adding your own node-edit-form.html.twig template to your subtheme with your own markup additions:

<div class="layout-node-form clearfix">
  <div class="layout-region layout-region-node-main">
    {{ form|without('advanced', 'actions') }}
  <div class="layout-region layout-region-node-secondary">
    {{ form.advanced }}
    <p>Random Markup</p>
  <div class="layout-region layout-region-node-footer">
    {{ form.actions }}
  • This is exactly what I was looking for. I didn't know about the "details" Form API element. Thank you!
    – kaldimar
    Commented Jul 21, 2016 at 15:33

Just place your block under Main content block on content region in Seven theme, It would place your block in bottom of the form, then you could design that with custom css.

Add the /node/*/edit /node/add/* paths in the block visibility field, it would add the block only on the node edit page, else the block will show in all the admin pages.

  • While this alternative works, I prefer Shawn's solution as it blends better with the form. This one would require a subtheme of Seven, or using a contrib module to inject styles in admin theme.
    – kaldimar
    Commented Jul 21, 2016 at 15:35
  • Yes, But the Shawn's solution also need custom module to edit the form, you could also add css from your custom modules. And also Block would be more user friendly for admin.
    – Leopathu
    Commented Jul 21, 2016 at 17:45

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.