Forum: Ruby on Rails disabled check_box does not work as expected?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
164bad3bfc412e3d0442d199a3780eff?d=identicon&s=25 oomtuinstoel (Guest)
on 2006-05-03 21:02
I have a checkbox:

<%= check_box(:day, :monday, {:disabled => ''} , (day.monday == true ?
{:checked => 'checked'} : {:checked => false} )) %>

It is disabled allright, but it is always uncecked. Is this supposed to
happen. It looks like

(day.monday == true ? {:checked => 'checked'} : {:checked => false} )

is not working if disabled is used...
6ded309a340360d5ae1f1efa4ac40837?d=identicon&s=25 Danger Stevens (Guest)
on 2006-05-03 21:57
(Received via mailing list)
oomtuinstoel <oomtuinstoelNO@...> writes:
> <%= check_box(:day, :monday, {:disabled => ''} , (day.monday == true ?
> {:checked => 'checked'} : {:checked => false} )) %>
>
> It is disabled allright, but it is always uncecked. Is this supposed to
> happen. It looks like
>
> (day.monday == true ? {:checked => 'checked'} : {:checked => false} )
>
> is not working if disabled is used...
>

I haven't looked at the rails code to verify this,
but it seems like it should be:
<%= check_box(:day, :monday, {:disabled => '', :checked =>
day.monday == true ? 'checked' : false } )) %>
164bad3bfc412e3d0442d199a3780eff?d=identicon&s=25 oomtuinstoel (Guest)
on 2006-05-04 13:35
>Danger Stevens wrote:
> I haven't looked at the rails code to verify this,
> but it seems like it should be:
> <%= check_box(:day, :monday, {:disabled => '', :checked =>
> day.monday == true ? 'checked' : false } )) %>

<%= check_box(:day, :monday, (day.monday == true ? {:checked =>
'checked', :disabled => ''} : {:checked => false, :disabled => ''} ) )
%>

dit the trick! Thanks for your pointer!
This topic is locked and can not be replied to.