Based on #2803875: Node form meta information should not come from a theme and #2882801: Review and improve the media creation form, I had the idea that we could let entity forms/modules opt-in to the seven sidebar by setting a flag on the form structure, for example $form['#sidebar'] = TRUE. possibly also on the specific elements that should be in the sidebar, although that could maybe be done through the existing group functionality as well.

Not sure yet about all the details, as the current implementation relies on a specific template that seven activates for node but is actually defined in node.module (yep, weird) and it does not have columns in node, but in *classy*.

So maybe instead of introducing a flag, we could just introduce a content-entity-edit-form template that seven can override and make it two-column? Not sure about BC for node, though.

CommentFileSizeAuthor
#71 core_allow_sidebar_for_content_entity_form_2893740_71.patch20.58 KBmrwhittaker
#68 core_allow_sidebar_for_content_entity_form_2893740_68_11.2.4.patch25.64 KBbogdan.dinu
#67 core_allow_sidebar_for_content_entity_form_2893740_66_11.x.patch27.09 KBbogdan.dinu
#67 core_allow_sidebar_for_content_entity_form_2893740_66_11.2.4.patch27.05 KBbogdan.dinu
#57 core_allow_sidebar_for_content_entity_form_2893740_57.patch21.04 KBbogdan.dinu
#52 2893740_51.patch21.25 KBimpol
#51 2893740_50.patch14.88 KBimpol
#49 2893740-49.patch31.54 KB_utsavsharma
#49 interdiff-48-49.txt11.8 KB_utsavsharma
#48 2893740_48.patch21.31 KBbogdan.dinu
#39 interdiff_2893740_37-39.txt2.4 KBankithashetty
#39 2893740-39.patch52.11 KBankithashetty
#37 interdiff-2893740-36_37.txt422 bytesgauravvvv
#37 2893740-37.patch51.67 KBgauravvvv
#36 2893740-36.drupal.Allow-the-seven-sidebar-for-the-node-form-to-be-used-on-other-entity-forms-as-well.patch31.61 KBjoachim
#35 interdiff.2893740.22-35.txt695 bytesjoachim
#35 2893740-35.drupal.Allow-the-seven-sidebar-for-the-node-form-to-be-used-on-other-entity-forms-as-well.patch31.38 KBjoachim
#32 Screenshot from 2021-11-05 17-31-39.png144.68 KBvikashsoni
#31 2893740-30-9.3.x.patch32.31 KBliquidcms
#26 2893740-26-8.9.x.patch31.84 KBmahseri
#25 2893740-25-8.9.x.patch32.23 KBmahseri
#24 2893740-24-8.9.x.patch31.87 KBmahseri
#23 2893740-23-8.9.x.patch31.76 KBmahseri
#22 2893740-17-9.3.x.patch34.05 KBabu-zakham
#17 2893740-17-9.1.x.patch31.3 KBseanb
#17 interdiff-15-17.txt2.28 KBseanb
#16 2893740-15-9.1.x.patch30.93 KBseanb
#15 2893740-15.patch30.93 KBseanb
#14 2893740-14.patch31.49 KBseanb
#14 claro-taxonomy.png71.49 KBseanb
#14 claro-node.png85.1 KBseanb
#14 claro-menu.png99.35 KBseanb
#14 claro-media.png86.8 KBseanb
#14 claro-block.png76.69 KBseanb
#14 seven-taxonomy.png71.12 KBseanb
#14 seven-node.png100.84 KBseanb
#14 seven-menu.png111.09 KBseanb
#14 seven-media.png73.91 KBseanb
#14 seven-block.png70.89 KBseanb

Issue fork drupal-2893740

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Berdir created an issue. See original summary.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

idebr’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pancho’s picture

Status: Active » Postponed

Think we need to postpone this on #2916809: Add fieldset/vertical tab for URL alias field as long as it’s a moving target. Might even become redundant, let’s see.

berdir’s picture

Status: Postponed » Active

I don't think those issues confict/need to block each other. In fact, they move in the same direction, by putting the path field also in the vertical tabs thing for other entity types, it also becomes available to be moved into the sidebar.

pancho’s picture

OK, sorry.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

marcoscano’s picture

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

seanb’s picture

Status: Active » Needs review
StatusFileSize
new70.89 KB
new73.91 KB
new111.09 KB
new100.84 KB
new71.12 KB
new76.69 KB
new86.8 KB
new99.35 KB
new85.1 KB
new71.49 KB
new31.49 KB

Ok I was finally able to give this a boost. Not sure about BC, but here is a patch to introduce a content-entity-form.html.twig with 2 columns that works for all content entity types like block content, taxonomy, media and nodes (even menu links, although it looks a bit sad since there is currently very little content in the sidebar).

But now that we have it, we might want to consider moving more fields, like taxonomy relations, menu link parent/weight etc.

Attached a patch and some screenshots for seven and claro.

seanb’s picture

StatusFileSize
new30.93 KB

Minor update to fix:

  1. +++ b/core/modules/system/templates/content-entity-form.html.twig
    @@ -0,0 +1,20 @@
    + * Default theme implementation for a node edit form.
    

    This should be updated.

  2. +++ b/core/modules/system/templates/content-entity-form.html.twig
    rename from core/themes/classy/templates/content-edit/node-edit-form.html.twig
    rename to core/profiles/demo_umami/themes/umami/templates/classy/content-edit/content-entity-form.html.twig
    

    This should be a copy.

seanb’s picture

StatusFileSize
new30.93 KB

Here is the same as #15 but for 9.1.x.

seanb’s picture

StatusFileSize
new2.28 KB
new31.3 KB
+++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php
@@ -99,19 +130,38 @@ protected function getBundleEntity() {
+      '#access' => $this->currentUser->hasPermission('administer nodes'),

We can't depend on the node permission here, so let's remove it. Also fixed some coding standards.

berdir’s picture

+++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php
@@ -99,19 +130,37 @@ protected function getBundleEntity() {
 
+    $form['meta'] = [
+      '#type' => 'container',
+      '#group' => 'advanced',
+      '#weight' => -10,
+      '#title' => $this->t('Status'),
+      '#attributes' => ['class' => ['entity-meta__header']],
+      '#tree' => TRUE,
+    ];
+
+    $form['footer'] = [

I think it's field group that has this thing that makes a wrapper thingy visible/accessible based on having any visible elements. do we need something like that?

And in general, do we need something to opt into this whole thing? We did that with the revision checkbox for example, to not having anything show up suddenly for existing content entity types. They might have have any fields to show in the sidebar if it's a custom thing so that might be quite confusing?

seanb’s picture

I guess a way to opt-in make it less likely to have issues for existing sites. Maybe some flag in the entity type annotation?

berdir’s picture

Yes, exactly, not just as BC, but there are content entities that aren't really _content_ where all of this doesn't make much sense. Just look at the user form with the patch applied, all you get is a last saved box in the sidebar :)

Or the comment form, which ends up getting some extra unstyled fields added in as well.

Or for a fun one, disable the admin theme on node forms. This is actually somewhat common when using node forms for less privileged users, so we also might need a setting on the theme level? Admin themes other than seven/claro might not be happy to have this thrown into their face either. Adding stuff is just so hard.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

abu-zakham’s picture

StatusFileSize
new34.05 KB

re-roll the patch to 9.3.x

mahseri’s picture

StatusFileSize
new31.76 KB

re-roll the patch to 8.9.x

mahseri’s picture

StatusFileSize
new31.87 KB
mahseri’s picture

StatusFileSize
new32.23 KB

Replace isPublished() with isActive() for the user entity.

mahseri’s picture

StatusFileSize
new31.84 KB

Published message only for Nodes

liquidcms’s picture

Spent an hour this morning trying to figure out why entity add form from contrib module wasn't using the sidebar. Glad i stumbled upon this - it seems to do the trick (#17 against 9.1.13)

Thanks guys.

liquidcms’s picture

Status: Needs review » Needs work

This will sound like a stretch.. but this patch breaks the Conditional Fields module working with Paragraphs. This patch makes major changes to ContentEntityForm.php and includes:

+    if ($this->entity instanceof EntityOwnerInterface) {
+      $form['meta']['author'] = [
+        '#type' => 'item',
+        '#title' => $this->t('Author'),
+        '#markup' => $this->entity->getOwner()->getAccountName(),
+        '#wrapper_attributes' => ['class' => ['entity-meta__author']],
+      ];
+    }

Which throws this error when trying to configure a conditional field:

Error: Call to a member function getAccountName() on null in Drupal\Core\Entity\ContentEntityForm->form() (line 200 of core/lib/Drupal/Core/Entity/ContentEntityForm.php).
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 532)
Drupal\Core\Form\FormBuilder->retrieveForm('paragraph_test_edit_form', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 568)
Drupal\conditional_fields\Form\ConditionalFieldEditForm->getDummyField('paragraph', 'test', Array, Object, Array) (Line: 171)
Drupal\conditional_fields\Form\ConditionalFieldEditForm->buildForm(Array, Object, 'paragraph', 'test', 'field_field_1', '1fa8cd98-876f-4ca5-b818-30b6e5ae64f2')
call_user_func_array(Array, Array) (Line: 532)
Drupal\Core\Form\FormBuilder->retrieveForm('conditional_field_edit_form', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)

My guess is, for those that don't know the CF module, is that the CF setting allows users to define the control value for a field using the fields defined widget. i.e. it shows the field's widget on its config form. My guess is this patch is being too liberal with where it tries to alter the entity form. It likely needs to be limited (by route??) to actually being on that form page. Just a thought.

berdir’s picture

Not that much of a stretch, this is definitely valid feedback. Node has basically always an owner, with enforced default values, but that assumption must not be made for other entity types.

The code there needs to check if an Owner is returned by getOwner() before calliing getAccountName() on it. This could also happen on any other entity type that for some reason does not have an owner.

liquidcms’s picture

@berdir, you are too fast.. took a look through code a bit and yes, exactly what you said. The paragraph entity is an instance of EntityOwnerInterface and therefore has the getOwner method; but this only returns a valid owner when the paragraph is attached to a parent (its normal use); but as CF is only pulling the form field in isolation of a parent; getOwner() returns NULL.

I'd likely wrap that entire field in the owner check:

if ($this->entity instanceof EntityOwnerInterface && $this->entity->getOwner()) {

}

I can do up the patch for this.

liquidcms’s picture

Status: Needs work » Needs review
StatusFileSize
new32.31 KB

patch for 9.3.x

vikashsoni’s picture

StatusFileSize
new144.68 KB

@liquidcms Patch giving error while applying
Needs to Re-roll for ref sharing screenshot

liquidcms’s picture

Hmm, not sure that patch has anything to do with those errors. The change I made is pretty minor, does the original 9.3 patch work for you?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

joachim’s picture

When I try to apply the latest patch I get lots of:

> (Stripping trailing CRs from patch.)

which might be why automated testing doesn't like it?

(BTW @vikashsoni there is no need to upload a screenshot of a failing patch, it's pointlessly using up storage space, it's enough to just say the patch doesn't apply.)

Here's a reroll on 9.4.x.

joachim’s picture

gauravvvv’s picture

StatusFileSize
new51.67 KB
new422 bytes

Re-rolled patch #36, I have provided a patch along with interdiff. Please review.

joachim’s picture

+++ b/core/themes/claro/css/layout/content-entity-form.css
@@ -6,7 +6,7 @@
+ * Layout overrides for content entity add/edit form.

In code, we should say 'node' rather than 'content entity'.

ankithashetty’s picture

StatusFileSize
new52.11 KB
new2.4 KB

Just fixed the custom command issues in #37 patch and made the change mentioned in #38, thanks!

Status: Needs review » Needs work

The last submitted patch, 39: 2893740-39.patch, failed testing. View results

carolpettirossi’s picture

Status: Needs work » Reviewed & tested by the community

I'm using the patch from #39 with Drupal 9.3.12 successfully =)

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

The CI isn't passing for #39 😥

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Title: Allow the seven sidebar for the node form to be used on other entity forms as well » Allow the sidebar for the node form to be used on other entity forms as well
Component: Seven theme » Claro theme

The Seven theme has been removed from Drupal 10 core. However, it looks like the most recent patch also changes the Claro theme to work in a similar way, so moving this to Claro for further discussion.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bogdan.racz’s picture

When using this patch in conjunction with the Webform module, the author meta information will always be there when the Webform is rendered.
Not being able to see the Author (user) name will result in a Label only form element.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bogdan.dinu’s picture

StatusFileSize
new21.31 KB

I've updated the patch from #39 to work with D10.1

_utsavsharma’s picture

StatusFileSize
new11.8 KB
new31.54 KB

Fixed CCF for 10.1.x.
Please review.

joachim’s picture

Component: Claro theme » entity system

I don't think this is in the right component, because most of the changes are in the entity component and the node module.

impol’s picture

StatusFileSize
new14.88 KB

Re-rolled #48 for 10.2.x

impol’s picture

Version: 11.x-dev » 10.2.x-dev
StatusFileSize
new21.25 KB

Fixed some missed files on #50

weri’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

If going to stick with patches please provide an interdiff between patches. #51 went from 31.54 to 14.88 with no interdiff or explanation.

Recommendation is MR btw.

Issue summary should follow standard issue template.

Thanks

angrytoast’s picture

https://www.drupal.org/project/drupal/issues/2519362 recently went into 11.x; it includes a form-two-columns abstraction which looks similar to what this issue is trying to achieve. Since that's actually in core and now a precedent, does it make sense for the work here to change and adapt to it?

Version: 10.2.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bogdan.dinu’s picture

I've updated the patch in#52 to work with D10.3

joachim’s picture

Made a MR from patch 57.

Tried to use the earlier patches as well, so it would preserve history, but there were too many added and rotted files -- couldn't find a core branch that the early patches would apply to (and it's surprisingly hard to find the answer to the question 'which core branch was the development branch on this date?')

joachim’s picture

> https://www.drupal.org/project/drupal/issues/2519362 recently went into 11.x; it includes a form-two-columns abstraction which looks similar to what this issue is trying to achieve. Since that's actually in core and now a precedent, does it make sense for the work here to change and adapt to it?

Yes, #2519362: Redesign the menu link add form to be less overwhelming goes in the right direction, but sadly it didn't generalise -- it adds a dedicated twig template for the menu item form.

We need to keep the generalized approach in this issue which adds a content_entity_form template.

anybody’s picture

Huge +1 on this for sbx. Currently, site builders don't understand why non-node entity forms look and behave different from node forms. It starts with taxonomy term editing and continues with widely used contrib entities like commerce products.

Adding tags accordingly.

ricardopeters’s picture

I'm not entirely sure I'm in the right place for this. But we're experiencing a probably unwanted side effect which is that webforms now show author information underneath the form, because of the way the patch adds the meta data.

Should webform handle this (and should I create a ticket within that project). Or is this backwards compatibility breaking, and should we handle it differently?

I see #46 adresses this aswell but I do not see a follow up, it might've gone overlooked?

ricardopeters’s picture

In light of the discussion of seanb and berdir in #19 and #20, the most BC friendly way to do this, would be having an configurable flag or indeed an annotation or a settable property, that would allow this to be optional. And maybe in a Major update enforce it, if that's a path we'd want to tale?

joachim’s picture

I think there's a cleaner way to do it than introducing an annotation flag:

- add a new class ContentEntityFormWithSidebar
- deprecate ContentEntityForm

Nothing changes for entities which use ContentEntityForm or a subclass of it.

Entity types should switch their form classes to using ContentEntityFormWithSidebar when they're ready.

Then in 12.x we remove ContentEntityForm, then rename ContentEntityFormWithSidebar to ContentEntityForm.

ricardopeters’s picture

Sounds like a clean solution indeed, I'd agree.

bogdan.dinu’s picture

I tried to rebase the MR and adapt the changes for 11.x but failed (I apologize, it was my first commit on a MR).

I still think the ContentEntityForm should have the sidebar by default because that is in my opinion the expected behavior for content entities, but I also understand that principle of finding a solution with minimal impact. For that reason I created new patches and a new MR based on @joachim's solution.

bogdan.dinu’s picture

I've updated the MR and also created a new patch for 11.2.4 with all the latest changes (do not use the previous ones).

joachim’s picture

My suggestion about deprecating form classes needs more detail -- I forgot about the twig templates that are involved too! Can twig templates be deprecated?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mrwhittaker’s picture

Re-rolled #57 for 10.6.3