In a node edit form i want to display an editable view, so an author can not only edit the node itself but also can alter some values of other nodes represented by the view, which is editable via the editable views module. How can i alter the node edit form in order to display that view?


4 Answers 4


It took me a while to find out how to do it in Drupal 8, and since this post is one of the first google hits I'll add the solution here:

function MODULE_form_node_NODETYPE_alter(&$form, FormStateInterface $form_state, $form_id) {
    $form['my_embedded_view'] = [
        '#type' => 'view',
        '#name' => 'my_view_name',
        '#display_id' => 'block_1',
        '#arguments' => [
            'arg1' => $arg_1,
            'arg2' => $arg_2,
        '#weight' => 30,
    ] ;

I used a block display for the view, I don't know if it's relevant.

  • Well, that doesn't work either: I was trying to accomplish exactly the same thing as Madam Adam, namely, to be able to edit the node and related entities brought in by the view, using the module views_entity_form_field. But the latter takes over the submit from the node edit page, so that the node cannot be modified. I made a few attempts to correct this problem, then I had to revert to the use of a custom page. Commented May 8, 2019 at 11:57
  • You can not use a default or main view. It has be something (embed, block, page, etc) in order for this to work.
    – MD3
    Commented Feb 6, 2021 at 5:25

The EmbeddedViewField module is able to render a view, regardless of whether the user is editing or displaying the entity (node) that has the EmbeddedViewField. Here is a quote about that module (from its project page):

... will allow you to render a view as any other field.

It is based on keithm's ViewField module, except that it will always render the view, regardless of whether the user is editing or displaying the entity that has the EmbeddedViewField. The view used for displaying is controlled by the default value set for the view.

This is useful in situations where you don't want end users to control the content being displayed by the view, but you still want a flexible way to insert content (views with text, images, media etc.) along with the rest of the fields in the form.

Context, Panels and Blocks could be used to place views and edit forms in the same page, but not to embed views between specific fields.


I solved the problem showing the view in the node edit form only by writing a tiny module containing this code:


 * Implementation of hook_form_alter()

function mymodulname_form_alter(&$form, &$form_state, $form_id){
     // target a single form only
  if($form_id == "mynodeform_node_form"){
      $form['html_markup'] = array(
        '#markup' =>views_embed_view('machinenameofmyview','default'),
        '#weight' => 1

There are a few ways you can do this - if you are using Drupal 7 - take a look at this module: https://drupal.org/project/token_embed_views Another less desireable way would be to use your PHP filter and the views_embed_view function https://api.drupal.org/api/views/views.module/function/views_embed_view/7

If you are looking to actually load this view in the edit side, you could possibly do a "hook_form_alter" to allow you to put your own content in the form...

  • My problem is not displaying a view, but displaying a view in node edit form only. Displaying a view is pretty easy with display suite and views content panes, but it's not possible to show this pane in edit form only.
    – Madam Adam
    Commented Apr 30, 2014 at 10:39
  • Glad you found the answer looks like we both were on the same page - not sure if my views_embed_view helped any our if you were already familiar
    – Sitori
    Commented May 21, 2014 at 19:11

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.