This project is archived and is in readonly mode.

#5332 ✓stale
Victor Costan

DEFAULT_*_OPTIONS cause inconsistencies in FormHelper

Reported by Victor Costan | August 8th, 2010 @ 12:33 AM

For example, DEFAULT_FIELD_OPTIONS is {'size' => 30}, which causes text_field to emit a size="30" HTML attribute. The inconsistencies are
in the RDoc; e.g., the 2nd and 3rd examples in texxt_field's RDoc are wrong in relation to FormTagHelper, which doesn't use these defaults; for example, un-styled text fields generated with text_field look different from those generated with text_field_tag

I would also argue that these defaults violate the principle of least surprise. They're also bad design practice, because they put presentation details in mark-up. Width and height should be specified via CSS.

I'll be happy to produce a patch that eliminates these defaults, if core likes the idea, and it would be accepted.

The DEFAULT*OPTIONS are constants and frozen hashes, so plug-ins shouldn't rely on being able to modify them. So I hope that removing them won't break too much 3rd party code.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages