Score:-1

How to remove author field from the 'advanced' field group on the node edit form

pe flag

I've got several node edit forms that, in most themes, display the 'advanced' group in a sidebar. I have other plans for the sidebar, though, so I don't want that behavior. I edited some twig and css to make the advanced group appear below the main form, but this is still pretty messy. In particular, we often have to adjust the author field, and I'd like it at the top all by its lovely self... not buried in a special section.

All of that to say, I see here how to add items to the 'advanced' group, but how can I remove author (and pretty much everything else) from it and just use the field group module to put fields where I want them? (Field group module currently doesn't let you take fields out of advanced)

I've done some things in MYTHEME.THEME with THEME_node_form_alter (changing submit button label for example), but I can't seem to get it to move author out of the advanced group.

The module way would be fine, too, but is beyond my expertise without some help. (Seems like there would be a market for a "liberate the node form" module or "all fields moveable" module, etc.)

Added because code requested...

function MYTHEME_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    $form['author']['#group'] = 'SOMETHING HERE?';
}

That isn't complete, so of course can't work. Looking at the api here, I see the author field is assigned to 'advanced' but I don't know how to assign it to something else. The relevant portion

$form['author'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Authoring information'),
    '#group' => 'advanced',
    '#attributes' => [
      'class' => [
        'node-form-author',
      ],
    ],
    '#attached' => [
      'library' => [
        'node/drupal.node',
      ],
    ],
    '#weight' => 90,
    '#optional' => TRUE,
  ];
apaderno avatar
us flag
Since this is a question about code, and you wrote code, we need to see that code. Otherwise, the question is too broad to be acceptable. We do not explain how to write a module, but if you do not understand a specific documentation page about writing a module, we could answer that, as long as the question is very specific (and it is not about the meaning of a single word used in that documentation page.)
pe flag
I really thought the code I linked to was clear enough, but have added some here. As the question says, I don't how to properly assign author to a different #group. I know how to make a module, but ... I don't know how to assign author to a different #group. If there's a reference document that lists all the possible #group values, that would be helpful. I tried 'footer' but I think my code is probably more fundamentally flawed because that got me a wsod.
Score:0
pe flag

This works... though it doesn't look quite right to me.

function MYTHEME_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
        $form['author']=['#group' => 'footer'];
    }

This sort of works, but is probably not a good idea. It removes author from 'advanced' but it doesn't seem to heed positioning in the "Manage form display" interface. And I get the impression fields are not supposed to be without a #group value.

function MYTHEME_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    unset($form['author']['#group']);
}
I sit in a Tesla and translated this thread with Ai:

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.