backdrop / backdrop-issues

Issue tracker for Backdrop core.
145 stars 40 forks source link

Field group functionality in core #647

Open sirkitree opened 9 years ago

sirkitree commented 9 years ago

Update 2023:

It has been decided that the field group module provides more options for field groups than we wish to include/support in core, so rather than move the entire module into core, we are planning to revamp the fieldgroup API and move certain types of field groups into core (groupings that already exist in core) and to leave others for the contrib module. The new fieldgroup API will become part of core's field + field_ui modules.

Group types planed for core:

Group types that should remain in contrib:

The Field Group contrib module would simultaneously release a new minor version (that depends on this version of Backdrop core) where those group types are removed from the module, and all remaining types are updated to use the core field group API (which will be similar to what's there already). The current group API will also be removed from the contrib module.

Requirements for getting new fieldgroup contrib module in core:


Original Issue: It would be pretty outstanding if we have field_group in core so that forms could be arranged a lot nicer with things like vertical tabs and such through the UI.

Requirements for getting fieldgroup contrib module in core:

User experience cleanup options:

New features (options):

Related issues:

Issue advocate: @jenlampton

klonos commented 1 year ago

@jenlampton this is indeed a huge change to be reviewing. Perhaps if we had a way to compare only commits after the contrib module was added (almost verbatim I'm assuming) as a starting point, then it'd be easier. Anyway, I don't know if there were other commits before the initial one, but I started reviewing one commit at a time as they are listed in https://github.com/backdrop/backdrop/pull/4076/commits

That's it for now - I'm sure I must have missed certain things, but once we have the main functionality in, we can iteratively improve/fix things.

jenlampton commented 1 year ago

I would much prefer it if we had separate FAPI elements for CSS classes/IDs, since both core and contrib is using those in settings forms.

Same. Could you create an issue for that? :)

similarly with CSS classes/IDs, I would like us to allow either commas or spaces, and then transparently remove commas in the form/field validation

Ooh, that's a good one! (But, for classes and not IDs, there can only ever be one ID) -- can you include that comment into the issue for the special forma API element?

jenlampton commented 1 year ago

I like the idea of making the ID field a '#type' => 'machine_name'

Now that I've read through your whole comment, I don't actually like using machine_name for a HTML ID attribute. Using a machine name would enforce that there is only one fieldgroup with each ID, and you might want one on each node type with the same ID, so I don't think this was a safe choice... I was trying to avoid the additional validators, but perhaps just removing it would be sufficient.

Not sure about the removal of the help text - there are some things that aren't straight-forward, unless you have used field groups before.

The concept of grouping fields is relatively simple (unlike layouts, for example). if we can guide people through using the form correctly as they are doing it, that would be a better experience than making people read about scenarios that may not apply to them.

We could be throwing "dirty form" warnings (for example when accordion items or vertical tabs are "parentless")

This does seem to be happening already (though sometimes you get the error from the previous setting, and sometimes you get the same one twice):

Screen Shot 2022-12-30 at 3 55 50 PM
klonos commented 1 year ago

Could you create an issue for that? :)

Done: #5898 ๐Ÿ˜‰

jenlampton commented 1 year ago

I filed a new PR that preserves the git history from field_group, and I'm hoping the sandbox will work on that one also ๐Ÿคž

jenlampton commented 1 year ago

It looks like I've got some failing tests, and we could use a little CSS cleanup for Seven, I'll work on those tomorrow. But the sandbox is back @klonos ! https://pr4289-ntjttt4v4pproevelni7ti26smnkxk3t.tugboatqa.com/node/add/page

jenlampton commented 1 year ago

I've fixed the failings tests! (I am also getting what I think is a random failure on LanguageUpgradePathTestCase, for only one version of PHP). I've got those running again.

I will start on some CSS cleanup for Seven (and I will test Basis also).

jenlampton commented 1 year ago

I've just noticed that field_group calls it's thingies both "Fieldgroups" (one word) and "Field groups" (two words) in both the user interface, and in code comments. I'm going to standardize on "Field groups" (but we can change that after Jan 1 if people prefer "Fieldgroups" :)

(I am not changing the permission administer fieldgroups, or the #fieldgroup property of render arrays, or fieldgroup-effects in the JS -- only code comments and user interface strings)

bugfolder commented 1 year ago

but we can change that after Jan 1 if people prefer "Fieldgroups"

I'll put my vote in for "Field groups."

jenlampton commented 1 year ago

One of the tests was failing because fieldgroup allowed people to select a "label element" for a "Details" group, but the Backdrop core details element always uses a span for this. The rendered output always added a second <span>around the "label element" that was selected, resulting in <span><span>, where the test was expecting only one.

My solution was to remove the label element, but I'm now thinking maybe I should have updated the test to search for the extra span, as the current solution would loose the functionality of being able to specify that tag... I'm going to go put that back, I don't want people to get different markup after switching to core fieldgroups...

edit: okay, I fixed it. Phew, close one :)

quicksketch commented 1 year ago

I haven't used Field Group module any time recently, so a lot of this module is new to me. In my own sites, I tend to form_alter() to achieve two things:

Reading this PR I see that Field Group module does a lot more than this. A lot of things make me nervous, like multipage and accordians. Do you think it would be feasible to instead put the API from Field Group module into core as part of Field module directly, and then make a "Field Group 2.x" that used the API to provide all the current functionality? Then maybe core could only worry about arranging forms and the most common features; and Field Group would maintain and provide an upgrade path for existing users of some of the more esoteric grouping options.

olafgrabienski commented 1 year ago

@quicksketch What's the reason for your nervousity: the number of features and options, or rather the technical architecture? I'm not able to evaluate the latter, but hope it can be improved by and by, if necessary. Re differentiating between 'most common' and 'more esoteric' features / options: While some use vertical tabs and fieldsets, others will want to use horizontal tabs and DIVs, and others even more. Which ones are common enough to be integrated in core?

Generally, as a site architect, I want to stay flexible and have all reasonable Field Group features in one place. And I'd like to avoid putting too less in core, forcing too many people to add the contrib module anyways.

klonos commented 1 year ago

Yeah, I'm also with @olafgrabienski on this @quicksketch. Field Group has a HUGE user base in Drupal, and it is a great low-code/no-code site builder tool (DX+) that helps bring sanity to content type forms (content editor UX+). It reminds me of the CCK and Views cases, where really popular modules got into core. We didn't include only portions or the API or only Views without the Views UI - we added these almost as they were.

Besides an indication of popularity, the mere fact that ~300k sites are using the module should be providing us enough confidence for its stability. Health-wise, there are currently 180 open bug reports in the d.org queue for the module, but only 86 of them for the 7.x version, and only 1 critical (which concerns an upgrade to a very dated version, from v1.3 to v1.4 which was released in 2014, whereas current is v1.8 released in October).

In Backdrop land, although they don't do the same thing, Field Group and Paragraphs are equally popular, with ~500 installations; there are only a handful of open issues in its queue; one of our core maintainers is already the maintainer of the contrib module, and it seems that we have @jenlampton and myself backing this (among other very active contributors in the community). These should all be things to factor in and provide some more reassurance and confidence. Right?

olafgrabienski commented 1 year ago

... the sandbox is back

I've had a look at the sandbox site yesterday and today. It worked generally fine, but today there were a few issues. (I didn't see the errors yesterday, they seem to have been introduced inbetween.)

olafgrabienski commented 1 year ago

When testing Field group, two questions came to my mind:

  1. Is Field Group supposed to be enabled by default? (In the sandbox, I had to enable the module.)

  2. Can we make the wording of the multi group types more consistent? It's just a small change, remove the term "item" from "Horizontal tab item".

herbdool commented 1 year ago

@quicksketch it's divided fairly cleanly between API and the group types so it can be done relatively easily. Just need to think of how to transition users with the upgrade so they use the right contrib module. I imagine a new contrib module would be needed for the extras and current contrib would be disabled upon upgrade.

herbdool commented 1 year ago

@quicksketch just reread your comment and understand better. If we put the API into Field module then we don't have to create a new contrib module. That'll be easier. Makes it harder to preserve commit history though?

herbdool commented 1 year ago

I think separating the functions out should first happen in contrib so it's easier to move around.

klonos commented 1 year ago

Is Field Group supposed to be enabled by default?...

If we decide to separate the UI (and implementations) out to contrib and only add the API into core, and also move the API into the Field module, then I guess that the API would always be enabled/available (the Field module is always required/enabled).

If we stick with how the module is in contrib now, then it wouldn't make sense to have it disabled once added to core. What would the point of it all then be? It's relatively the same to have the module in core and disabled (where people need to enable it to be able to use its features) and have it in contrib (where people can get it via the Project Browser, enable it, and then use it). I thought that the goal was to have it enabled OOTB + then perhaps follow up with a way to demo its use in one of the existing content types. That way people would be able to get an example use case and tweak further (rather than having to discover that this feature exists in the first place).

jenlampton commented 1 year ago

Do you think it would be feasible to instead put the API from Field Group module into core as part of Field module directly, and then make a "Field Group 2.x" that used the API to provide all the current functionality? Then maybe core could only worry about arranging forms and the most common features; and Field Group would maintain and provide an upgrade path for existing users of some of the more esoteric grouping options.

I really like this idea. After doing a lot of work on the module I also learned about strange things that it does that probably shouldn't be in core (yes accordions and multipage elements, but also collapsible divs?!?).

I was previously more concerned about the upgrade path, and wanted everyone running field_group to NOT need to install a field_group_extras module to get the same behavior after the core update.

If we, instead, moved the API, and maybe just a few group types (fieldset, details, and vertical tab come to mind) into the core Field UI module, everything else could remain in field_group, and people previously using field_group would have a seamless upgrade path.

I don't think we should add an API without core uses of the API. We should include a few implementations.

While some use vertical tabs and fieldsets, others will want to use horizontal tabs and DIVs, and others even more

There's one pretty clear place to draw a line: Core could support all the elements we already have in core, and everything else could remain in contrib. We'd essentially be adding an API, and then implementing the API to support everything that already exists.

What's the reason for your nervousity: the number of features and options, or rather the technical architecture?

For me it's both.

I think separating the functions out should first happen in contrib so it's easier to move around.

I'm happy to help with that. I would also like to contribute some individual patches with things like UX improvements and coding standards cleanup so that the work from the current PR isn't lost.

@herbdool I could see field_group 2.0 simply switching from the current API to the new core API, and removing the group types now provided by core. Core could handle any configuration changes that were necessary for those group types (If there are any, but I'd prefer there weren't!) and as long as the 2.0 version has a dependency on the version of core that gets the API, the upgrade path should be smooth.

Makes it harder to preserve commit history though?

Yeah, I can't think of how we could do that...

quicksketch commented 1 year ago

Generally, as a site architect, I want to stay flexible and have all reasonable Field Group features in one place. And I'd like to avoid putting too less in core, forcing too many people to add the contrib module anyways.

I suppose I'm not in the majority here, but I've personally never used Field Group module, and if I did, it would be to only organize the edit form fields, not to modify the front-end display. I think I'm most worried about the burden of needing to support entirely new display styles like horizontal tabs on the front-end. Basis will probably need to be updated to at least minimally support every Field Group display style, as will any future core themes.

If we put the API into Field module then we don't have to create a new contrib module. That'll be easier. Makes it harder to preserve commit history though?

That's right, what I was thinking is that Field module would adopt the API, and provide vertical tab and fieldset group types. Then Field Group module would continue to live in contrib and provide all the other group types.

But if we were to follow that plan, developers that use Field Group as a site-building tool would very likely still need to use the contrib module.

klonos commented 1 year ago

...I do like the flexibility of making those things possible - hence the API.

My only concern with this thinking is that the API is a developer tool - excluding the current implementations from the contrib module would mean that people still need the contrib module.

I've personally never used Field Group module, ...

Yes, because as you've mentioned in one of your earlier comments, you code your way out of things required. Not everyone can do that though.

...and if I did, it would be to only organize the edit form fields, not to modify the front-end display.

Yes, this is a great tool for site builders to provide friendlier forms for content editors with minimal effort (no code). That's why I like it.

fieldset, details, and vertical tab come to mind

In GovCMS, I've seen frequent use of horizontal tabs, as well as the sidebar implementation (but that's only a D8+ thing, so not in the 7.x version of the module).

herbdool commented 1 year ago

@jenlampton @quicksketch I think we're on the same page.

jenlampton commented 1 year ago

I've updated the main issue with the current plan as I understand it. Resetting labels.

docwilmot commented 1 year ago

Is someone working on it though?

stpaultim commented 11 months ago

This issue just came up in Zulip. It is currently item 4 on our Feature Request Wishlist.

There was a lot of excitement about this issue a year ago and some of us thought it was very close to going into core. As I review the most recent comments, it seems that some reconsideration is happening (or has been decided). As I understand it, both @jenlampton, @quicksketch, and others now believe that this module MIGHT be doing more than necessary or at least more that we wish to support in core.

The current plan seems to be to move some of the API's into core and to keep the User Interface in contrib. The original issue description (but not it's title) has been updated to reflect this.

Personally, I understand that this might be the smart course of action, but I don't remember the discussion and am concerned that this was a popular feature request, because folks wanted the UI in core not just the API. Moving the API may benefit developers, but it will not benefit site architects/builders.

I'm not necessarily opposed to this plan, but I would like clarification. While supportive of either option, I less excited about the API only idea.

If the scope has changed as indicated, maybe the title of the issue should be changed to "Field Group API in Core."

avpaderno commented 11 months ago

@stpaultim Reading the issue summary, I gather the aim is to include in core some of the group types the contributed module provides, not to include only the module API in core, at least because there is the Integrate Fieldgroup API into field/field_ui modules list item.

klonos commented 11 months ago

Yup, what @kiamlaluno said is right @stpaultim - the decision was to add the UI for this as well, but to provide support for only some of the most common grouping elements and then leave the rest of them for the contrib module.

stpaultim commented 11 months ago

Thanks to @kiamlaluno and @klonos for clarification. I will edit the original issue to make that a bit clearer, but I think it was the most recent comments in issue that confused me.

The next thing I'm looking for clarification on is what is the next step. Does this mean we're waiting on someone to start refactoring the existing contrib module to move some code into a completely new PR, while revising the old contrib module to work with the API's that will now be in core?

Is there any usable work that has been done already or are we looking for someone to start over on this task?

avpaderno commented 11 months ago

There were two PRs, but one was closed in favor of the other one, and https://github.com/backdrop/backdrop/pull/4289 was said to be rejected by core committers.
I guess this needs to be started over, but I am not sure which approach should be followed, nor why the previous approach has been rejected.

avpaderno commented 11 months ago

(Never mind: The new plan should be the one described before Original issue, which in fact has a list with no checked item.)

avpaderno commented 11 months ago

I am in favor of this feature, but I do not know how to contribute. The first point (Integrate Fieldgroup API into field/field_ui modules) is rather broad. I would not know what should be done to keep the commit history from the contributed module.

klonos commented 11 months ago

Here's a rough plan the way I understand things:

herbdool commented 11 months ago

@kiamlaluno the plan is to get the contrib module in a state that is acceptable for core first. This may mean making a sub-module to move the features there, which won't be merged into core. Then when core is released, make a new version of the contrib module that is only for those who've upgraded.

So you can contribute by going to the contrib module and helping with blockers.