Rails not editable text field
I have form_for written as follows:
<div class="field"> <%= location.label :city %> <%= location.text_field :city, :disabled=>true%> </div> <div class="field"> <%= location.label :country %> <%= location.text_field :country, :disabled=>true%> </div> As you can see, textbox 2 is disabled because they are autocomplete by the jquery function, and I don't want the user to process them. The problem is that in this way, the view does not pass these parameters to the controller, because it is disabled !!! Is there any other way to pass a non-editable text field to the controller, fearing that I do not want to use a hidden field, because I want to show the results to the user inside the text field.
Tnx
Do it read only!
<%= location.text_field :country,:readonly => true%> The trick is to use the βobjectβ along with the label for everything you donβt want to change. Here's how you should encode it:
<%= location.label(:country, f.object.country) %>