Jeffrey Guenther
Jeffrey Guenther

Reputation: 901

Why is setting a form builder "readonly" in not working?

Rails Noob here.

I have the following code in my _form.html.erb:

 <%= f.time_select :slotTime,
  { :readonly => true, :ampm => true, :minute_step => 30} %>

When I view the page in my web browser the time selector drop downs are not disabled. I have used similar code for other text_fields and it works. Do you know why this might not work?

I have tried:

:readonly => true

and

:readonly => "readonly"

as is suggested by other questions. What am I missing?

Upvotes: 0

Views: 710

Answers (1)

mu is too short
mu is too short

Reputation: 434785

You want :readonly to end up as an HTML attribute and that makes it an HTML option; HTML options go in the second Hash so I think you want this:

<%= f.time_select :slotTime,
  { :ampm => true, :minute_step => 30},
  { :readonly => true }
%>

Upvotes: 1

Related Questions