While trying to fix #107038: Javascript to select module dependencies I needed to have the 'readonly' state working.

This patch makes it applicable to an element, although the proper support for it may only apply to text and password input fields.

I was trying to use it with a checkbox and Firefox still allowed me to check and uncheck it, even though it 'greyed out' as if it was disabled.

Maybe other browsers support it better.

João Ventura

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dig1’s picture

Version: 7.x-dev » 8.x-dev

João, can you provide some code to replicate the problem? (Moving issue to 8.x-dev.).

xjm’s picture

Issue tags: +Novice, +Needs manual testing

I checked with ksenzee about this issue in IRC. So it sounds like the readonly state is not working properly in FF?

References:

So what we would probably want to do here is create a test form with one checkbox element and a readonly state. Then, we'd test the form, trigger the state, and see what happened in Firefox. A patch or code snippet with a sample form would be good.

Tagging novice to give this a shot. Try creating a test form and reproducing the error described in the original post.

Everett Zufelt’s picture

Issue tags: +html5

http://miketaylr.com/code/input-type-attr.html

I can't find a better source, and I don't recall if the HTML5 spec is clear at all, but I know that I've read that @readonly is only valid on some input types. The above reference shows hat it does not apply to checkbox.

cosmicdreams’s picture

Assigned: Unassigned » cosmicdreams

I'll see if I can manually test this tonight.

xjm’s picture

A reroll with git/8.x would be cool while you're at it. :) Edit: Also, check out this test module for testing:
http://drupal.org/sandbox/rfay/1269964

cosmicdreams’s picture

FileSize
512 bytes

Here's the reroll

xjm’s picture

Hmm, I just re-read #3 -- does that mean this patch is not a valid change? I'll ping nod_.

nod_’s picture

Found this: http://dev.w3.org/html5/spec/the-input-element.html#concept-input-immutable

So readonly is not supposed to work for checkboxes (at least not work like it does for textarea or other inputs types), I guess we can add it, it might not work the same across browsers though. So i don't really know what to do.

nod_’s picture

Status: Needs review » Postponed (maintainer needs more info)

I'll let that out of the review queue. I just don't know what's the best way to deal with that.

jcnventura’s picture

cosmicdreams's patch in #6 can't be right.. It closes a block midway leaving some functionality for the block it starts...

I only read the patch, though..

nod_’s picture

Don't take it the wrong way but you're probably not used to reading patches. Testbot didn't complain so it apply properly (at the time at least).

jcnventura’s picture

@nod_: I do take it the wrong way. I'd appreciate if you check someone's experience in d.o, before accusing someone of 'inexperience'. I still maintain #6 can't be right. You may be the one that don't have experience in checking facts before answering an issue... But maybe you were having a bad day.

The fact is #6 closes a block mid-way, and starts a new one. Some functionality that applied to the old block is no longer used in that Javascript event flow, and becomes part of the new event. Since this is introducing a new event, the code should look different.
See my patch in the original post for how it should look like (in terms of block opening/closing).

nod_’s picture

Version: 8.0.x-dev » 8.1.x-dev
Issue summary: View changes

Gosh, past me sure could be a prick. I'm sorry @jcnventura.

Unless we don't have a compelling reason to put that in 8.0.x, I'd rather not touch the states API at this point.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Needs work

Yes, I agree. This should be now 8.1.x material. And like I said, I wasn't asking you to apologize. People do have bad days. I didn't get (too) angry at the time.

But let's change the status on this. The readonly attribute should now have better browser support. My original patch was too simple, it should only apply to text controls as per the spec.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgifford’s picture

Assigned: cosmicdreams » Unassigned

Unassigning stale issue. Hopefully someone else will pursue this.

zuhair_ak’s picture

So, what would be the verdict? How should we proceed?

jcnventura’s picture

@zuhair_zyxware: try to figure out where the original patch (not #6) introduced the readonly handling in the new code.. That code was for D7, maybe it helps to look at it there also.

The code is also too simple, there should be some code preventing it to be applied to anything other than textual input fields (no radios/checkboxes).

tstoeckler’s picture

Issue tags: +DrupalBCDays

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

_Archy_’s picture

Couldn't we just support "readonly" checkboxes/radios by setting the original to disabled and cloning it to a hidden input? So in that way it would still submit.

_Archy_’s picture

Issue tags: +DCTransylvania

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

GrandmaGlassesRopeMan’s picture

Issue tags: +Vienna2017, +Needs tests
Ivan Berezhnov’s picture

Issue tags: +CSKyiv18

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sunlix’s picture

Status: Needs work » Closed (outdated)
Related issues: +#2866383: Readonly doesn't work on #States

I close this as this is out of date: see #2866383: Readonly doesn't work on #States