This page is an example to show how to use the readonly attribute for
checkbox
, radio
and select
helpers.
Taken from the docs:
Both the disabled
and readonly
attributes for an input prevent the user from modify it. However, the disabled
attribute means this input will NOT be sent within the POST request, whereas the readonly
one means it will.
Nevertheless, for checkbox
, radio
and select
tags it doesn't happen. To support the readonly
attribute for these tags, the corresponding helpers have been adapted to behave as would be expected. To do that, when the readonly
attribute appears the helper will:
disabled
attribute<input type="hidden">
with the desired valuecheckbox-group
, radio-group
or select-group
)readonly
attribute is present, even with a false value. It is done to make it easier to modify its readonly
behaviour using javascript.
This demo shows a form with a text field that is always editable and readonly checkbox
,
radio
and select
fields. Submit the form to see that the readonly fields are correctly handled. You will see the fields rendered as GET params at the end of the URL of this page. You can "unlock" or "lock" them with the corresponding button using javascript.
Bound data:
Check here the CoffeScript code used for lock and unlock the fields.