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.

| Comment | File | Size | Author |
|---|---|---|---|
| #71 | core_allow_sidebar_for_content_entity_form_2893740_71.patch | 20.58 KB | mrwhittaker |
| #68 | core_allow_sidebar_for_content_entity_form_2893740_68_11.2.4.patch | 25.64 KB | bogdan.dinu |
| #57 | core_allow_sidebar_for_content_entity_form_2893740_57.patch | 21.04 KB | bogdan.dinu |
| #52 | 2893740_51.patch | 21.25 KB | impol |
| #49 | 2893740-49.patch | 31.54 KB | _utsavsharma |
Issue fork drupal-2893740
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
Comment #3
idebr commentedRelated issue in the Field group (contrib) module: #2652642: Allow to position the group in the advanced (sidebar) column
Comment #5
panchoThink 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.
Comment #6
berdirI 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.
Comment #7
panchoOK, sorry.
Comment #9
marcoscanoSlightly related.
Comment #14
seanbOk 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.twigwith 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.
Comment #15
seanbMinor update to fix:
This should be updated.
This should be a copy.
Comment #16
seanbHere is the same as #15 but for 9.1.x.
Comment #17
seanbWe can't depend on the node permission here, so let's remove it. Also fixed some coding standards.
Comment #18
berdirI 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?
Comment #19
seanbI guess a way to opt-in make it less likely to have issues for existing sites. Maybe some flag in the entity type annotation?
Comment #20
berdirYes, 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.
Comment #22
abu-zakham commentedre-roll the patch to 9.3.x
Comment #23
mahseri commentedre-roll the patch to 8.9.x
Comment #24
mahseri commentedComment #25
mahseri commentedReplace isPublished() with isActive() for the user entity.
Comment #26
mahseri commentedPublished message only for Nodes
Comment #27
liquidcms commentedSpent 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.
Comment #28
liquidcms commentedThis 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:
Which throws this error when trying to configure a conditional field:
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.
Comment #29
berdirNot 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.
Comment #30
liquidcms commented@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:
I can do up the patch for this.
Comment #31
liquidcms commentedpatch for 9.3.x
Comment #32
vikashsoni commented@liquidcms Patch giving error while applying
Needs to Re-roll for ref sharing screenshot
Comment #33
liquidcms commentedHmm, 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?
Comment #35
joachim commentedWhen 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.
Comment #36
joachim commentedFixed the missing parameter docs.
Comment #37
gauravvvv commentedRe-rolled patch #36, I have provided a patch along with interdiff. Please review.
Comment #38
joachim commentedIn code, we should say 'node' rather than 'content entity'.
Comment #39
ankithashettyJust fixed the custom command issues in #37 patch and made the change mentioned in #38, thanks!
Comment #41
carolpettirossi commentedI'm using the patch from #39 with Drupal 9.3.12 successfully =)
Comment #42
lauriiiThe CI isn't passing for #39 😥
Comment #44
longwaveThe 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.
Comment #46
bogdan.racz commentedWhen 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.
Comment #48
bogdan.dinu commentedI've updated the patch from #39 to work with D10.1
Comment #49
_utsavsharma commentedFixed CCF for 10.1.x.
Please review.
Comment #50
joachim commentedI don't think this is in the right component, because most of the changes are in the entity component and the node module.
Comment #51
impol commentedRe-rolled #48 for 10.2.x
Comment #52
impol commentedFixed some missed files on #50
Comment #53
weri commentedComment #54
smustgrave commentedIf 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
Comment #55
angrytoast commentedhttps://www.drupal.org/project/drupal/issues/2519362 recently went into 11.x; it includes a
form-two-columnsabstraction 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?Comment #57
bogdan.dinu commentedI've updated the patch in#52 to work with D10.3
Comment #59
joachim commentedMade 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?')
Comment #60
joachim commented> 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.
Comment #61
anybodyHuge +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.
Comment #62
ricardopeters commentedI'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?
Comment #63
ricardopeters commentedIn 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?
Comment #64
joachim commentedI 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.
Comment #65
ricardopeters commentedSounds like a clean solution indeed, I'd agree.
Comment #67
bogdan.dinu commentedI 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.
Comment #68
bogdan.dinu commentedI'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).
Comment #69
joachim commentedMy suggestion about deprecating form classes needs more detail -- I forgot about the twig templates that are involved too! Can twig templates be deprecated?
Comment #71
mrwhittaker commentedRe-rolled #57 for 10.6.3