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.

Comments

webchick’s picture

Title: More common on form elements » Change defaults on form elements to most common values

Not sure how I broke my title so much hehe.

hunmonk’s picture

+1. coding style is good. idea is solid. let's get this sucker in!

chx’s picture

Status: Needs review » Reviewed & tested by the community
m3avrck’s picture

genius! where or where was this patch last week!

dries’s picture

Status: Reviewed & tested by the community » Needs work

I expected that this patch would simplify some existing code ... Please update the existing code.

webchick’s picture

StatusFileSize
new81.09 KB

Ah, 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

webchick’s picture

Status: Needs work » Needs review

Sorry. Ready for review again, I think!

dries’s picture

Status: Needs review » Needs work

Committed this patch, though, parts of it did not apply. Can you look into those? Thanks.

webchick’s picture

Status: Needs work » Needs review
StatusFileSize
new6.04 KB

Ok. 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.

eaton’s picture

+1 *thank* you! Node forms were looking mighty tiny when the previous patch went through.

webchick’s picture

Category: feature » bug

Changing status from feature request to bug report.

m3avrck’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly and fixes the *tiny* node edit boxes, please commit!

asimmonds’s picture

Priority: Normal » Critical
StatusFileSize
new5.18 KB

Re-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.

Stefan Nagtegaal’s picture

Maybe 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.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)