I am having trouble setting readonly => true on a form helper. It still allows me to change the selection. Here is my code.
<%= f.date_select :date_of_birth, {:order => [:day, :month, :year]}, {:readonly => true} %>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
readonlyoption does not exist in the HTML<select>-tag or<otption>-tag and even Rails cannot magically add such an option to HTML..!Instead, you can use
:disabled => true, to show the select fields as ‘disabled’:Values of disabled fields are not send with the form though, so if this is required, you need to add a copy of the field as hidden as well.
This hidden field/value is then send with the form, and the disabled field is shown in on your page.