Posted by KiberGus on December 1, 2007 at 10:47am
5 followers
Jump to:
| Project: | Drupal core |
| Version: | 7.x-dev |
| Component: | system.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
By default textfields width is set using "size" property. This is not good, if you have narrow theme or you want to stretch element to the full width of page. For example I wanted to put textfields in two columns, but they appeared to be wider, than columns.
So I neede to set not "size", but "style='width:N%'". Element can't have negative size, so I overloaded it: if value is positive you get usual behavour, if it is negative, you get width property set.
All you have to change is to replace line 1396 of forms.inc (first line in function theme_textfield($element)) with:
$size = $element['#size'] ? ($element['#size']>=0? ' size="' . $element['#size'] . '"' : ' style="width:'.-$element['#size'].'%"' ) : '';This patch is against 5.2.
Comments
#1
Please have a look on this page on how to create patches. Also, if the 'patch' is for 5.2, why not version it as such?
#2
Marked #222175: Don't hardcode field size and #210149: form input field is not sizeable as a duplicate of this issue to bring together the efforts.
The problem is form input elements are given a size in system_elements() that doesn't work well with narrower themes. The size should be a styling only I think.
#3
I guess I don't see the issue. I have never had a problem styling a form element with css.
#element_id {
width: 2px;
}
#4
Yeah, I've explored this a little bit more, and that works for most fields. In 6 the file upload field doesn't work with CSS styling when the element already has a size though. I'm still investigating.
#5
Size of input fields is in number of characters. The width in pixels is up to the theme in use (CSS-only issue), so there is nothing to do in Drupal core itself (unless one of the core themes gets it wrong). Closing.