Forum: Ruby on Rails Checkbox readonly

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.
C14805404d3f08ba9b1f6ad93c01615f?d=identicon&s=25 Daniel Wijnands (dewie)
on 2005-12-21 11:38
I declare some checkboxes :

<%= check_box_tag 'offers[]', offer.id ,
@params[:offers].include?(offer.id.to_s) ,:readonly=>true %>

the result is :

<input checked="checked" id="offers[]" name="offers[]"
readonly="readonly" type="checkbox" value="1" />

But readonly doesn't work ???
A13967d343cd6d6028cee84a227a2f8d?d=identicon&s=25 Ali Hamidi (Guest)
on 2005-12-21 11:52
daniel wijnands wrote:
>
> I declare some checkboxes :
>
> <%= check_box_tag 'offers[]', offer.id ,
> @params[:offers].include?(offer.id.to_s) ,:readonly=>true %>
>
> the result is :
>
> <input checked="checked" id="offers[]" name="offers[]"
> readonly="readonly" type="checkbox" value="1" />
>
> But readonly doesn't work ???

Hi,

this site might be of some use to you:
http://www.htmlcodetutorial.com/forms/_INPUT_DISABLED.html

In a nutshell it explains that READONLY only prevents users from
changing the VALUE. i.e. the user can still interact with the checkbox.
Perhaps DISABLED is what you're looking for.

Ali
C14805404d3f08ba9b1f6ad93c01615f?d=identicon&s=25 Daniel Wijnands (dewie)
on 2005-12-21 12:34
disabled doesn't get posted in the browser, readonly does.
so i need readonly, i want the values but they cannot edit them :)



Ali Hamidi wrote:
> daniel wijnands wrote:
>>
>> I declare some checkboxes :
>>
>> <%= check_box_tag 'offers[]', offer.id ,
>> @params[:offers].include?(offer.id.to_s) ,:readonly=>true %>
>>
>> the result is :
>>
>> <input checked="checked" id="offers[]" name="offers[]"
>> readonly="readonly" type="checkbox" value="1" />
>>
>> But readonly doesn't work ???
>
> Hi,
>
> this site might be of some use to you:
> http://www.htmlcodetutorial.com/forms/_INPUT_DISABLED.html
>
> In a nutshell it explains that READONLY only prevents users from
> changing the VALUE. i.e. the user can still interact with the checkbox.
> Perhaps DISABLED is what you're looking for.
>
> Ali
071aec714fe5f3fe5b1df9fc5adb45f2?d=identicon&s=25 Raghuraman Suraj (Guest)
on 2005-12-21 13:00
(Received via mailing list)
With what i understand a readonly property works with textbox & textarea
and all but not with a checkbox, if u want to make the checkbox non
editable by the user u have to make the disabled property true, to still
get the value either have a hidden input or make the disabled property
false onsubmit
This topic is locked and can not be replied to.