This project is archived and is in readonly mode.

#4839 ✓resolved
Jeff Dean

[PATCH] form fields should allow developers to set values to nil

Reported by Jeff Dean | June 12th, 2010 @ 01:25 AM

Currently you cannot set the value of a text_field or hidden_field to nil:

f.text_field :some_field, :value => nil # => will output an input with a value equal to f.object.some_field

I consider this a bug because it is inconsistent with other attributes of text_field. If I specify :class => nil, it will omit the class attribute, but if I specify :value => nil, I get the default value. It is valid HTML to have an input of type "text" with no value attribute, and I think rails should respect the developers intentions if they want to omit it.

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=""></a>


Referenced by