Forum: Ruby on Rails How can I append a text_field_tag to a form_for?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Heinz S. (Guest)
on 2009-03-12 17:35
Hello people,

how can I append a text_field_tag to a form_for? When I submit the form
all text_field_tags are not being appended to the params...
Tom H. (Guest)
on 2009-03-12 18:02
You probably just have a typo in your code...

If you include a

   <%= text_field_tag 'firstname' %>

in your form, then you can get the value in the controller using


If you use nested resources, a

   <%= text_field_tag 'user[firstname]' %>

in your form, will result in


in your controller.

Heinz S. (Guest)
on 2009-03-12 18:07
I have it exactly like you said:
<%= text_field_tag "type[#{}]", 0, :size => 1, :id =>
"type_#{}", :disabled => true %>
or rather:
<input id="type_826889617" type="text" value="0" size="1"
name="type[Tarnung]" disabled="disabled"/>

But I only get the fields used with the form_for (all form.text_field
inputs). None of the text_field_tags is in the params array.
Ar C. (Guest)
on 2009-03-12 18:31
Disabled items don't come back in the params, perhaps you need a hidden

I just tweaked the first name field on a person edit form to be
disabled, and the value did not come back in the params.
Heinz S. (Guest)
on 2009-03-12 19:14
Yeah, that was it. Thanks :)
This topic is locked and can not be replied to.