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
Comment | File | Size | Author |
---|---|---|---|
#6 | 900590-6-readonly.patch | 512 bytes | cosmicdreams |
fapi_states_readonly.patch | 469 bytes | jcnventura | |
Comments
Comment #1
Dig1 CreditAttribution: Dig1 commentedJoão, can you provide some code to replicate the problem? (Moving issue to 8.x-dev.).
Comment #2
xjmI 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.
Comment #3
Everett Zufelt CreditAttribution: Everett Zufelt commentedhttp://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.
Comment #4
cosmicdreams CreditAttribution: cosmicdreams commentedI'll see if I can manually test this tonight.
Comment #5
xjmA 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
Comment #6
cosmicdreams CreditAttribution: cosmicdreams commentedHere's the reroll
Comment #7
xjmHmm, I just re-read #3 -- does that mean this patch is not a valid change? I'll ping nod_.
Comment #8
nod_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.
Comment #9
nod_I'll let that out of the review queue. I just don't know what's the best way to deal with that.
Comment #10
jcnventura CreditAttribution: jcnventura commentedcosmicdreams'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..
Comment #11
nod_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).
Comment #12
jcnventura CreditAttribution: jcnventura commented@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).
Comment #13
nod_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.
Comment #14
jcnventura CreditAttribution: jcnventura commentedYes, 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.
Comment #16
mgiffordUnassigning stale issue. Hopefully someone else will pursue this.
Comment #17
zuhair_akSo, what would be the verdict? How should we proceed?
Comment #18
jcnventura CreditAttribution: jcnventura commented@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).
Comment #19
tstoecklerComment #22
_Archy_ CreditAttribution: _Archy_ at PitechPlus commentedCouldn'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.
Comment #23
_Archy_ CreditAttribution: _Archy_ at PitechPlus commentedComment #25
GrandmaGlassesRopeManComment #26
Ivan Berezhnov CreditAttribution: Ivan Berezhnov as a volunteer and at Drupal Ukraine Community for Levi9 commentedComment #37
sunlixI close this as this is out of date: see #2866383: Readonly doesn't work on #States