[drupal-devel] [feature] Form groups should be collapsible

Dries drupal-devel at drupal.org
Wed Jan 26 09:37:42 UTC 2005


 Project:      Drupal
 Version:      4.5.2
 Component:    base system
 Category:     feature requests
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  tangent
 Updated by:   Dries
 Status:       patch

Looks good (though I haven't looked at the code).

The node-edit/submit form would be an obvious candidate for this kind
of stuff.

Interesting!

Dries



Previous comments:
------------------------------------------------------------------------

January 26, 2005 - 05:42 : tangent

Attachment: http://drupal.org/files/issues/collapsible_formgroups.patch (2.8 KB)

With all the talk of form reorganization and with the latest attempts at
coding a solution, I thought I'd step up and contribute my solution. It
is a quick development that I just threw together and it will probably
need to be expanded to support more options, but it works and it has
zero impact on existing code other than a small change to
form_groups(). I've added an optional boolean parameter called
"collapsed" so that modules can specify if the group should be
initially collapsed or not.

Known issues:
1. Styling the collapsed forms to look the same or even just good in
every browser may prove troublesome. It looks fine in Mozilla/Firefox
but the legend jumps around a bit in IE. I'm not terribly concerned
about that at the moment though.

2. Required fields are not handled so a collapsed fieldset *could*
contain a required field. This will need to be dealt with before this
is a real solution, in my opinion. The difficulty lies in the fact that
required fields are not labeled (in the markup) as such, other than by
adding an extran span. Maybe we should think about adding a "required"
attribute to required fields.

I'm attaching the patch (against HEAD) now and will attach the
javascript file shortly as well as a test page so you can see the
functionality.

As an aside, I'm setting this issue to patch status since that seems to
be the process used around here. However, I think that generally an
issue should ONLY be set to patch status if the attached file is worthy
of being commited. Please correct me if I have misunderstood.

------------------------------------------------------------------------

January 26, 2005 - 05:44 : tangent

Attachment: http://drupal.org/files/issues/drupal.js (1.68 KB)

Here's the (new) drupal.js file. Note that don't necessarily think the
functions included in it need to be loaded for every request. If more
javascript is added, it should probably be broken up into separate
pieces that can be sourced as need.

------------------------------------------------------------------------

January 26, 2005 - 05:46 : tangent

Attachment: http://drupal.org/files/issues/fieldset_test.html (3.41 KB)

Here's a stand-alone test page so you can see what the functionality
would be like. Please report any issues with specific browsers by
attaching your user-agent string or a description of your browser and
the issue. Screenshots are welcome.

------------------------------------------------------------------------

January 26, 2005 - 10:22 : Junyor

FYI, window.addEventListener is not supported in Opera.

------------------------------------------------------------------------

January 26, 2005 - 10:27 : chx

A cross browser solution to add event listeners can be found at
http://www.scottandrew.com/weblog/articles/cbs-events

That one works with Opera.

------------------------------------------------------------------------

January 26, 2005 - 10:45 : tangent

Attachment: http://drupal.org/files/issues/fieldset_test2.html (3.84 KB)

Here's an update of the test page. You should see the toggle image now
and I've added extra event handling for all those substandard browsers
;-)

I also corrected an issue where, if javascript is disabled, the group
could be collapsed and not expandable.

------------------------------------------------------------------------

January 26, 2005 - 10:48 : tangent

For what it's worth, if this functionality doesn't work in some browsers
that's ok. As long as the code fails silently everything else will
degrade nicely and they'll simply see all the forms.

------------------------------------------------------------------------

January 26, 2005 - 11:08 : tangent

Attachment: http://drupal.org/files/issues/fieldset_test3.html (4.06 KB)

This one might work better. I missed some stuff if the last one. I don't
have Opera or Konqueror to test with though.

I'm working a method to deal with required fields next.

-- 
View: http://drupal.org/node/16204
Edit: http://drupal.org/project/comments/add/16204





More information about the drupal-devel mailing list