Score:0

Programmatically add Views block to field group

jp flag

I want to programmatically add a view to a field group I created using the field_group module. I created an group_articles tab field group.

When I do this something like hook_form_alter:

    $form['issues__articles'] = array(
      '#type' => 'fieldgroup',
      '#weight' => 0,
    );
    $form['issues__articles']['view'] = [
      '#type' => 'view',
      '#name' => 'view_admin',
      '#display_id' => 'block_1',
      '#weight' => 0,
    ];
    $form['issues__articles']['#group'] = 'group_articles';

My view is added to my premade group_articles group, inside a programmatically created fieldset. I can change fieldgroup in my code into details and this would also work. But I don't want a fieldset or details container I want the view without a container or a simple html element like div and then inside my group_articles tab.

Changing fieldgroup to html_element doesn't work and removing the first part like this:

$form['issues__articles']['view'] = [
  '#type' => 'view',
  '#name' => 'view_admin',
  '#display_id' => 'block_1',
  '#weight' => 0,
];
$form['issues__articles']['#group'] = 'group_articles';

Or:

$form['issues__articles'] = [
          '#type' => 'view',
          '#name' => 'view_admin',
          '#display_id' => 'block_1',
          '#weight' => 0,
        ];
        $form['issues__articles']['#group'] = 'group_articles';

Also doesn't work, how can I fix this?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.