# Disabled check\_box does not work as expected?

**URL:** <https://www.ruby-forum.com/t/disabled-check-box-does-not-work-as-expected/59524>\
**Category:** Rails\
**Created:** [May 3, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/disabled-check-box-does-not-work-as-expected/59524 "2006-05-03T21:02:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oomtuinstoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/a87d85/32.png) [@oomtuinstoel](https://www.ruby-forum.com/u/oomtuinstoel)\
**Post date:** [May 3, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/disabled-check-box-does-not-work-as-expected/59524/1 "2006-05-03T21:02:01Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![oomtuinstoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/a87d85/32.png) [@oomtuinstoel](https://www.ruby-forum.com/u/oomtuinstoel)\
**Post date:** [May 3, 2006, 9:57pm UTC](https://www.ruby-forum.com/t/disabled-check-box-does-not-work-as-expected/59524/2 "2006-05-03T21:57:51Z")

</div>

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 } )) %\>

---

<div class="post-metadata">

**Author:** ![oomtuinstoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/a87d85/32.png) [@oomtuinstoel](https://www.ruby-forum.com/u/oomtuinstoel)\
**Post date:** [May 4, 2006, 1:35pm UTC](https://www.ruby-forum.com/t/disabled-check-box-does-not-work-as-expected/59524/3 "2006-05-04T13:35:41Z")

</div>

> 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!
