This simple patch will change the defaults of textfields, passwords, and textareas to the most commonly used values throughout Drupal core. The end result? Hey, it will save you some typing unless your fields deviate from the standard size, because you won't have to re-declare these values in your form declaration -- only #type and #title. :)
--
Textfield:
size - 60
maxlength - 128 (was 70, which is only used once)
This happens to coincide with the default settings for the node title field, which will be declared in every node type since in 4.7 it is no longer declared automatically.
--
Textarea:
cols: 60
rows: 5 (was 20, which is never used)
This happens to coincide with the default settings for the node body field, which will be declared in most node types.
--
Password:
size - 30 (was 60, which is never used)
maxlength - 64 (was 70, which is never used)
This one was kind of a crapshoot... there are 4 places in user.module where password fields are declared, and all of them have different values -- 30 was used twice for size, and 64 was used twice for maxlength so I went with those. In any case though, it definitely shouldn't be 60 and 70.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | form_defaults_2.patch | 5.18 KB | asimmonds |
| #9 | form_defaults_1.patch | 6.04 KB | webchick |
| #6 | form_defaults_0.patch | 81.09 KB | webchick |
| system.elements.patch | 1.37 KB | webchick |
Comments
Comment #1
webchickNot sure how I broke my title so much hehe.
Comment #2
hunmonk commented+1. coding style is good. idea is solid. let's get this sucker in!
Comment #3
chx commentedComment #4
m3avrck commentedgenius! where or where was this patch last week!
Comment #5
dries commentedI expected that this patch would simplify some existing code ... Please update the existing code.
Comment #6
webchickAh, you are right. Ok, here is a patch that contains the "new and improved" defaults, as well as the removal of all redundant values throughout core.
Values removed are:
checkbox:
#return_value => 1
checkboxes:
#tree => TRUE
fieldset:
#collapsed => FALSE
#collapsible => FALSE
file:
#size => 60
password:
#size => 30
#maxlength => 64
textfield:
#size => 60
#maxlength => 128
textarea:
#cols => 60
#rows => 5
weight:
#delta => 10
Comment #7
webchickSorry. Ready for review again, I think!
Comment #8
dries commentedCommitted this patch, though, parts of it did not apply. Can you look into those? Thanks.
Comment #9
webchickOk. Here is an updated patch that fixes a couple formatting isues, and also put node bodies back to #rows => 20 (my mistake before -- there are still way more #rows => 5 than #rows => 20, so the default value should remain, but node bodies look very silly at the moment).
I scoured the code from the current HEAD though and couldn't find any instance of old values anywhere? So it looks like everything that needed to, applied.
Comment #10
eaton commented+1 *thank* you! Node forms were looking mighty tiny when the previous patch went through.
Comment #11
webchickChanging status from feature request to bug report.
Comment #12
m3avrck commentedPatch applies cleanly and fixes the *tiny* node edit boxes, please commit!
Comment #13
asimmonds commentedRe-rolled patch from #9 for current HEAD and have tested it, fixes the tiny node edit textareas.
Changing to critical as I think it's required for the 4.7 RC.
Comment #14
Stefan Nagtegaal commentedMaybe it's just me who thinks this, but isn't it better to introduce textual sizes for the amount of rows, so we force consistency?
For example:
'#rows' => 'small', '#rows' => 'medium', '#rows' => 'large'
Where small is '5', medium '10' and large '20'? Just doing a guess...
I think this would be better for standardizing the code and to get to a consistent look-and-feel of drupal.
Comment #15
dries commentedCommitted to HEAD. Thanks.
Comment #16
(not verified) commented