[Rails] Re: A quick question on forms

Ben Lisbakken
Tue, 18 Jul 2006 11:43:13 -0000

SSpalding wrote:
> I want to change parts of this form in order to use default values (with
> a
> disabled input). The problem is if I change it from text_field to
> text_field_tag that part of the form stops functioning. It seems like a
> silly question, but its been driving me crazy. Any help would help.
>
> Steve.
>
> <%= error_messages_for ''post'' %>
>
>
> <label
for="post_title">Title
> <%= text_field ''post'', ''title''
%>

well to give this a set value and make it read only, change it to:
<%= text_field ''post'', ''title'', :value
=> "This is the title that
appears", :readonly => true  %>

or you could make it a hidden field:
<%= hidden_field ''post'', ''title'', :value
=> "You won''t see this but it
will get passed to the destination as params[:post].title"  %>


Hope that works!

Ben Lisbakken

--
Posted via http://www.ruby-forum.com/.