How can I append a text_field_tag to a form_for?

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…

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.


I have it exactly like you said:
<%= text_field_tag “type[#{}]”, 0, :size => 1, :id =>
“type_#{}”, :disabled => true %>
or rather:

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.

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.

Yeah, that was it. Thanks :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs