Slinky
Slinky

Reputation: 5832

Rails 2.2.2 Form Input Field as Read Only

I inherited an older Rails 2.2.2 project and I am trying to make a few text fields read-only but when I added:

:readonly => true

It isn't working, even after a restart and looking at the source, it looks like Rails is just ignoring that hash value. Here is the entire snippet from the view:

<%= f.text_field :password %> <%= link_to "Generate", {},:readonly => true, :class => "small_link_button", :onclick => "generatePassword(); return false;" %>

Upvotes: 2

Views: 2537

Answers (1)

Eric S
Eric S

Reputation: 1363

It looks like you put readonly on the link, not the text_field. Consider trying this:

<%= f.text_field :password, :readonly=>true %> 
<%= link_to "Generate", {}, :class => "small_link_button", :onclick => "generatePassword(); return false;" %>

Upvotes: 5

Related Questions