Set the radio form field type to read only

74 views
Skip to first unread message

Ryan Matthews

unread,
Jan 26, 2016, 3:30:09 PM1/26/16
to Joomla! General Development
Hello, I am trying to set the radio form field type to read only but it still allows the user to edit the field. 

Here's my \models\forms\component.xml:

<field
name="scheduled"
type="radio"
readonly="true"
class="btn-group btn-group-yesno"
label="COM_ENTRYMGMT_ENTRYMGMT_FIELD_SCHEDULED_LABEL"
description="COM_ENTRYMGMT_ENTRYMGMT_FIELD_SCHEDULED_DESC"
required="false"
>
<option value="1">COM_ENTRYMGMT_ENTRYMGMT_VALUE_YES</option>
<option value="0">COM_ENTRYMGMT_ENTRYMGMT_VALUE_NO</option>
</field> 


Niv Froehlich

unread,
Jan 26, 2016, 4:02:04 PM1/26/16
to joomla-de...@googlegroups.com
Hi Ryan,

Interesting!  I haven't tested either of these (it's not always a 'best-practice' to include read only radio-buttons (see discussion in 2nd link)), but these resources might be helpful as they cover 'read only' attributes for form inputs.

https://www.sitepoint.com/community/t/read-only-radio-buttons/26225/4


http://stackoverflow.com/questions/16109358/what-is-the-correct-readonly-attribute-syntax-for-input-text-elements

Check the syntax of 'readonly' in your HTML output and see if matches the second and third links above.  The third links provides insight suggesting that 

readonly="true"

is incorrect syntax - perhaps readonly="readonly" would work.

For example

<input type="text" value="myvalue" class="class anotherclass" readonly="readonly" />

Hope that helps - please post back to let me know.

Cheers,




--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Ryan Matthews

unread,
Jan 27, 2016, 9:47:40 AM1/27/16
to Joomla! General Development
Great suggestions and thanks for the helpful links! I never knew there were so many valid ways to declare an input field as 'readonly'! However, your suggestion of readonly="readonly" does not work and it was the presence of the "class="btn-group btn-group-yesno"" that enabled the user to continue to edit the field. When I removed that class attribute and stayed with "readonly="true"", the radio button was not editable as desired.

Does this classify as a Joomla bug (and if so, how do I notify the devs?)?

Ryan
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.

Michael Babker

unread,
Jan 27, 2016, 10:06:46 AM1/27/16
to joomla-de...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.

Ryan Matthews

unread,
Jan 27, 2016, 10:30:24 AM1/27/16
to Joomla! General Development
Thanks, posted!
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages