[drupal-devel] [feature] Patch to add 'wide' to class of wide form
items. (Solves theme problems with wide fields.)
jjeff
drupal-devel at drupal.org
Wed Aug 3 01:09:32 UTC 2005
Issue status update for
http://drupal.org/node/28044
Post a follow up:
http://drupal.org/project/comments/add/28044
Project: Drupal
Version: cvs
Component: base system
Category: feature requests
Priority: normal
Assigned to: jjeff
Reported by: jjeff
Updated by: jjeff
Status: patch (code needs review)
Hmm... that brings this from simple to complicated very quickly.
But I can understand the need for some for smaller fields to respect
their parent's width as in blocks or other side content.
How about this solution (notice last argument):
<?php
function form_textfield($title, $name, $value, $size, $maxlength,
$description = NULL, $attributes = NULL, $required = FALSE, $fullwidth
= FALSE) {
?>
This would be backward compatible with all existing modules, but it
would give developers a chance to make their intentions about the width
rendering of a form field completely clear. If fullwidth is set to TRUE,
then "fullwidth" is added to the item's class.
And we'd be looking at this in drupal.css:
.form-item .wide {
width: 100%;
}
And then all textfield, password, textarea, or autocomplete form items
in the core should probably be examined for intent and patched
appropriately.
I realize that it's a little confusing to have both a 'size' argument
in addition to 'fullwidth' when you really just want to have your field
be the width of the block, but remember that 'size' is an html tag and
the 'fullwidth' class is a css tag. In the interest of compliance, we
should probably keep both.
-Jeff
jjeff
Previous comments:
------------------------------------------------------------------------
Tue, 02 Aug 2005 15:13:29 +0000 : jjeff
Attachment: http://drupal.org/files/issues/common.wide.patch (5.33 KB)
We've all seen wide Drupal forms break a fixed width theme by "blowing
out" the right side of the theme. Here's a solution to the problem.
This patch adds a "wide" class tag to any textfield, password,
textarea, or autocomplete form item with a width (size) of more than 40
characters. By also adding a css rule in drupal.css that sets any "wide"
form-items to width:100%, we keep these form items under control. Of
course the assumption is that any form items with a width greater than
40 are intended to be full width. Opposing viewpoints are welcome.
Here's the css rule:
.form-item .wide {
width: 100%;
}
patch for common.inc is attached.
------------------------------------------------------------------------
Tue, 02 Aug 2005 15:45:46 +0000 : Prometheus6
Actually, I use this rule in my style.css:
form {
width: 95%
}
------------------------------------------------------------------------
Tue, 02 Aug 2005 18:12:25 +0000 : drumm
I think this is greatly needed.
I do not think making any form element with a size greater than 40 into
a wide field is a good idea. For forms in blocks a wide field might have
a smaller size.
A better way to implement this would be using a special value of the
$size argument to mean 'wide'. This could be 0 and may have an
associated constant such as FORM_WIDE. When the size is 0 then that
attribute may be omitted and the class added. This is a lot more to
patch since that requires finding every call to form_* which has a
large width, but I think the result will be worth it.
More information about the drupal-devel
mailing list