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

Files: 
CommentFileSizeAuthor
#6 900590-6-readonly.patch512 bytescosmicdreams
PASSED: [[SimpleTest]]: [MySQL] 34,786 pass(es). View
fapi_states_readonly.patch469 bytesjcnventura
PASSED: [[SimpleTest]]: [MySQL] 23,302 pass(es). View

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
PASSED: [[SimpleTest]]: [MySQL] 34,786 pass(es). View

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