I installed fieldgroup for a large form, containing over 60 fields, which ultimately were placed into 12 groups.

After spending quite a while putting things into groups and weighting them appropriately (e.g., city, state, zip into an address group, etc.) I was really disappointed to discover that there is no output to match. It wouldn't always be true, but I believe it is often true, that the logical organization created with fieldgroup would be desired in the output, too, at least by default.

As is, city, state, zip for example are not only not together, they are in fact spread out by their individual weight far from one another because they're interspersed with the other 11 groups. This is true in both the "manage fields" screen and in the templates.

I don't rightly know which module would be responsible for honoring the fieldgroup weights . . . it seems like CCK and the content.module is probably where it happens? If fieldgroup is only responsible for creating the weights and I need to ask elsewhere for things to allow the choice of using those weights, I'd sure appreciate a pointer to where this request belongs.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

yeah, doing this in 4.7 would require work on the cck module - I also agree the best thing would be fieldgroup support in the cck core.

associated cck issue

fago’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

for 5.x this should be doable as part of the module

fago’s picture

Project: Fieldgroup » Content Construction Kit (CCK)
Component: Code » fieldgroup.module
KarenS’s picture

Requested again at http://drupal.org/node/107665.

yched’s picture

kuahyeow’s picture

Sorry for the duplicate.

Just to add my .02 here, it is really odd that fieldgroup has been included into CCK core, but it only changes the input form. Ideally, WYSIWYG should apply here, especially with regards to structure and ordering of elements.

dkruglyak’s picture

Any chance this gets backported to 4.7.x?

kuahyeow’s picture

Don't know, there isn't even a patch to speak of.

Of course, you can soft of workaorund this by using contemplate. [ http://drupal.org/project/contemplate ]

ps. I say, sort of, because, this approach clearly is tedious, when you have move than 5 elements. [have you seen the output?]. Clearly sensible defaults should be applied here.

yched’s picture

The easiest and most logical way considering current implementation (fieldgroup.module acts mainly from the outside) would be to alter the displayed content with hook_content_alter, just the same way the form is altered with hook_form_alter.

But this is 5.0 only, unfortunately. At first glance, having this in 4.7 would require not minor rewrinting.

yched’s picture

This gets a lot of duplicate requests, so I'll get to it. As explained in my previous post, this will be 5.0 only for now.

littleprince’s picture

Omigosh. This is my #1 issue with this module. I never realized it when I quickly evaluated and started a new site based on Drupal just because of the flexibility I thought the CCK Module would offer. After doing a bunch of work, and than entering a bunch of data, I quickly realized this would be a chore.

I would love to help anyone who wants to work on this, but I am very new to Drupal, and am still finding everything a little confusing.

On a related note, the Fields / Groups should be seperated from Body.

yched’s picture

I committed the feature to 5.0 branch
By default it displays fieldgroups as fieldsets (themable), and adds additional 'collapsible' and 'collapsed' for display time.
Maybe we'll want to disable this for teasers, though, and keep only the weighting part (comments welcome)

The new settings require running update.php

littleprince’s picture

Thank you so much for looking into this.
I couldn't get it to work.

I downloaded Drupal 5.1, the latest stable CCK for 5.x, installed them both. I than downloaded the 2 files for 5.x that you committed to CVS and replaced them in the CCK folder. I than ran update.php

When I try to add a group, I get this
user warning: Column count doesn't match value count at row 1 query: INSERT INTO node_group (type_name, group_name, label, settings, weight) VALUES ('lcd_tv_01', 'group_video', 'Video', 'a:2:{s:4:\"form\";a:3:{s:11:\"collapsible\";i:1;s:9:\"collapsed\";i:0;s:11:\"description\";s:0:\"\";}s:7:\"display\";a:3:{s:11:\"collapsible\";i:0;s:9:\"collapsed\";i:0;s:11:\"description\";s:0:\"\";}}', '0', 0) in D:\WebApps\includes\database.mysql.inc on line 172.

I think this is a huge step in the right direction however, and see the huge potential of the display fields tabs.

PS this also didn't work for me when I just patched my working installation and hence the test on a clean install.

Did I do something wrong?

littleprince’s picture

Removed a %s, from line 193 in fieldgroup.module seems to fix insertion of a new group.
Haven't tested other parts yet.

yched’s picture

doh. fixed now. thanks :-)

littleprince’s picture

No, thank you yched!

You saved me another day of headaches of playing with Drupal to make this work. I will be reviewing your code this weekend and hopefully well learn some insights into the system.

fago’s picture

great work yched, thanks too :)
I've just committed another tiny fix, so that the display fieldgroup uses the appropriate settings (it had used the form settings before).

I would suggest to add the groups to the Display field tab too, so that they can be disabled for teasers too.
Opinions?

yched’s picture

display setting fix : Er, right, wrong copy / paste :-/. Thanks.

'display fields' tab : Yes, I think this is the next logical step.
We could provide pseudo-formatters for the fieldgroups (a simple div / a fieldset)
This would incidentally solve the 'do you want fieldsets in your teasers' issue.
Unfortunately, I'm not too familiar with the way Karen included the fieldsets in the 'Manage Fields' tab overview,..

fago’s picture

Category: feature » task

another idea:
implement the radio buttons, that are proposed in this issue: http://drupal.org/node/101243
Then remove this radio buttons from the edit-group display settings, but move it into the display fields tab by allowing one to select between:

hidden //the complete fieldset + its fields will be hidden
open
collapsible
collapsed

However, the display-description would stay alone in the edit-group form..

yched’s picture

Yes, that's basically what I had in mind with my 'pseudo formatters'. We'd have something like :
- simple (div)
- fieldset
- fieldset - collapsible
- fieldset - collapsed
- hidden

Whether we shape the UI with radios or dropdown selects is only a matter of choice (even if a select would be more consistent with actual fields formatters :-) )

fago’s picture

ok, I'll have a look at it

fago’s picture

Status: Active » Needs review
FileSize
11.59 KB

attached is the patch - please test: especially if the update procedure keeps correctly the collapsible/collapsed settings.

littleprince’s picture

Would it be possible to combine this new code with the nested fieldgroup patch?

yched’s picture

FileSize
13.59 KB

Here's a new version of the patch :
- update function now directly queries db tables - I had a hard time debugging content and field modules upgrade functions that used API functions (you don't know in update_n what db scheme they rely on), it seems safer to avoid doing so when we can :-)
- simplified the logic in the theme function, to allow easier theming
- removed theme('box'), not flexible enough (no description, no outer div, no attributes) - we provide our own 'simple display' theme function.
- added some margins and padding in a fieldgroup.css file - so tiny it could be integrated directly in content.css ?
(I could not integrate it in the patch, so it will be attached in my next post)
- added another display option : 'no styling' - no visual weez, same display as before my commit in #12 (except for the order of fields)

yched’s picture

FileSize
94 bytes

and the css (remove the .txt extension ...)

yched’s picture

BTW, this makes me wonder if we really want the fieldset-style display...

fago’s picture

Strange that I had one reject while applying the patch, however attached is another version (including the css file).
- fixed the hidden display

yep, I also thought about this. Aren't fieldset meant for grouping forms?
I looked up the w3c specs and found nothing that prohibits the use of fieldsets without forms, but a div might still suit better.
However I really like the js functionality of fieldsets for display too: e.g. display the fieldset collapsed in the teaser and expanded for full node view: great :)
Of course we could redo that, for a fieldset-display-div, but I suppose that would require a new js file.

yched’s picture

Status: Needs review » Reviewed & tested by the community

Well, I really don't think there's anything wrong with fieldsets in a non-form context. So if we want the functionnality, it's much easier to use core's collapsible fieldsets without reinventing our own collapsible divs. But I was just wondering if it wasn't too much of a gadget,... I guess if you do like the feature, then we have our answer...

I think in most cases users will probably want a no-style or a 'simple' div - but if for any reason a collapsible fieldset comes handy, they'll have to override the theme function for all fieldgroups to get them it, if we don't provide it.

So, all in all, i think this is rtbc :-)

fago’s picture

Status: Reviewed & tested by the community » Fixed

agreed & committed to 5.x and HEAD :)

yched’s picture

Great !
I opened http://drupal.org/node/117132 for the completion of the 'display field' tab overview.

yched’s picture

Category: task » feature

BTW, this is still an open feature request for 4.7 branch...

yched’s picture

Status: Fixed » Active
fago’s picture

Version: 5.x-1.x-dev » 4.7.x-1.x-dev
Status: Active » Closed (won't fix)

I personally have no interest in implementing this feature in 4.7.x as it would be more complicated then in 5.x. So I set this to won't fix for 4.7 - if anyone else wants to do it, just reopen it.