-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to have disabled form controls to be submitted (was: readonly attribute) #2311
Comments
See https://html.spec.whatwg.org/#the-input-element:attr-input-readonly-3 for which types it applies. What would it do for the other types? Why would it be nice? What problem are you trying to solve? |
The url basically verifies what I said: that "readonly" applies only to text based form elements.
The important thing is to prohibit the users from changing the value. For example, if it's a multiple select, let them scroll in order to see which values are selected (just like readonly works with textarea).
Because it already exists in text based form elements and in terms of squared logic it should be also applied to other form elements as well.
Imagine a form where a user should be able to change only certain fields, while others must be "readonly". You could say that I could just use "disabled" instead of "readonly". The problem with disabled is that it doesn't post the value. And there are cases where the value must be posted (ie the value is calculated in the front-end, and the back-end can't calculate it). There are workarounds, but it would be way easier if the browser could do it. |
Well, everybody can have his own opinion. I believe that there is valid business behind it to support this feature (as explained above). Is there any workaround? Sure there is, but it requires extra code and depending on the project this might be easy or very difficult (imagine a generic form builder platform for example). So, since it's do-able with one or another way, why not just do it with a single word: "readonly"? Thank you |
@othermaciej makes good points in the email cited above that I think you would need to address if you want to have any success in convincing implementors to change this. (Maciej's opinion is very relevant in terms of what is likely to be implemented or not in WebKit.) In particular a new attribute like https://bugzilla.mozilla.org/show_bug.cgi?id=88512 shows that |
Hello again, Mozilla obviously dropped this bug, because it's not a bug.
ref: https://www.w3.org/TR/html4/interact/forms.html#edef-INPUT It might not be in the BFN of the spec, but it has the comment "-- for text and passwd --" next to it.
ref: https://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-readonly Looks like the whole As I said before, we can debate years on a simple feature, but that's just pointless.
To those that advocate against I think my arguments are fairly reasonable. Please do let me know otherwise. Thank you for your time |
Right. The reaction could have been "Oh, let's change the standard" (like you propose here), but it wasn't. Let's ignore what HTML4 says, it's not relevant.
The first page of results is mostly relevant, but it seems to me most of the hits have nothing to do with the feature you're asking for. So it's an irrelevant number.
For controls where
The point is that
Assume one browser has implemented the new feature, and the others have not yet. To use it, you still need to have some sort of fallback (like a polyfill) to get the right behavior in the other browsers. How would you check for support for With a new attribute, feature-checking is simple:
|
I guess that they didn't care, since it was not their responsibility.
Right: the appearance between
That's a good point indeed. The thing is that businesswize, |
Hixie participated in that bug, and he was revamping the forms standard at that time to add new features. He took on responsibility to fix the standard, but did not add this feature. Rendering is defined in https://html.spec.whatwg.org/#rendering although it is lacking for form controls in general and doesn't say anything about
You don't have to use
That seems to confuse matters even more...
I suspect that is not web compatible. |
I think what this issue needs is stated interest from a browser vendor to solve this problem at all. Bikeshedding about the syntax isn't going to get us forward. |
This is Hixie's only useful-on-the-topic post that I found from the bug report that you mentioned and I quote it here:
I think I've made my argument about this idea on my previous posts:
What I'm trying to say is that Hixie didn't add the
So you basically say that for
Why? You introduce a new attribute that has a new function. It happens all the time:) |
I'm not sure I quite follow you. |
My bringing up Hixie was in response to your comment:
I had in mind this comment in particular: https://bugzilla.mozilla.org/show_bug.cgi?id=88512#c28 That is, I claim that somebody cared and took responsibility. That is all. It does not need to affect what we do today. 😊
Correct.
No. See https://wiki.whatwg.org/wiki/FAQ#Is_there_a_process_for_adding_new_features_to_a_specification.3F although actually steps 7, 8 and 9 should happen more in parallel. We need stated interest from 2+ implementors and tests before landing changes to the standard. Also see https://blog.whatwg.org/improving-interoperability |
So, I basically have to contact firefox and chrome developers and convince them that this is a hot topic to start working on it? :) |
For the specific use case of making a control disabled to the user, but still submitting the contents, it seems like this can be achieved by having a parallel that contains the same data. Your client-side logic would have to update both of course. I am not saying this is a super elegant way to do it, but the use case seems very narrow, and I am not sure it is worthwhile to add a new feature for it. The use case, as described, is that some state is calculated on the client side, must be shown to, but not edited by the user, and can't readily be recalculated by the server. That seems pretty rare. And there is a workaround. Admittedly a clunky one, but for a rare case, is that not good enough? |
Do you remember I believe a good standard shouldn't consider only just how popular a feature is, in order to incorporated it or not. Instead, it should help as much as possible the users to work as better as possible, and adding a bunch of extra unnecessary boilerplate in their code to do something that is basically the responsibility of another's layer (the browser), given also the fact that it's 2017 (and not 20 years ago), certainly isn't much of a help. By definition, workarounds exist because something else doesn't work as it should. There is always the option to continue arguing about this for the next 20 years, or fix it in just a few days. Logic and evolution votes the latter. Resisting to change is pointless, just embrace it:) |
Hi @othermaciej, in my 10.0 version of Safari, Has that changed in 10.1? |
@chaals Pretty sure that's a bug in both cases. |
Quite possibly. For Currently it means that there is no interop for these input types - which was the case a year ago when I was looking, so there doesn't seem to be a lot of motivation from browsers in deciding one way or another. |
So, any comments on my last post? |
@ilisepe1 yes. I recommend filing an issue and point to this one. https://bugzilla.mozilla.org/enter_bug.cgi?product=Core |
@chaals I did not find any other issues about readonly applying (or not) for color or range in webkit/chromium/mozilla bug trackers. Filed: (No wpt since this requires user interaction.) |
Back on topic... https://bugzilla.mozilla.org/show_bug.cgi?id=1338535 In the mozilla bug @ilisepe1 commented
Myself and @annevk discussed this a bit in #whatwg
|
Better title:) I'm glad that you are discussing the feature. |
Looks like there is tentative support from Gecko and Chromium:
@othermaciej - the stackoverflow threads suggest this is not in fact a rare problem, and the workarounds are clunky indeed. Is it reasonable to expect WebKit to follow if we standardize something here and it is implemented in Gecko/Chromium, or are there any objections? |
@zcorpan If it goes in the standard, WebKit would not specifically hold out, though it wouldn't necessarily be a high implementation priority. It's not important enough either way to be worth fighting over. I will say that I do not personally find the case for this feature compelling. Five question threads over a span of seven years is not very strong evidence of demand for this functionality. As a counterpoint, I note that apparently JS framework authors have not added anything to support this specific use case. JS frameworks typically have a lot more convenience features than the base platform, yet they have not judged it worthwhile to provide a packaged workaround. On the cost side, form controls and their many attributes are already a complicated area of the web platform, and fairly complicated implementation-wise. The bar for adding a new attribute to that is ultimately a convenience feature should be pretty high. It's likely we'll have complexity creep for forms anyway, for new basic capabilities. So the payoff should be really high. In conclusion, while I don't specifically think the feature is terrible, there is some cost to adding it, and in my opinion the evidence does not show strong demand. Further, I would not necessarily interpret the comments in the Gecko and Chromium as "tentatively support". The most I could say of those comments is that they show non-refusal. Is this because developers of those engines actively think it's a good idea, or merely that it wouldn't be worth disputing if it was in the spec? These comments show that the feature would not be blocked but I don' think they make a positive case for adding it. Notwithstanding my opinion (that this feature does not add enough value for the complexity cost), we'll respect the judgment of the spec editors on this. If it's in the spec and in other browsers, then we'll very likely implement it sooner or later. Please do not interpret this statement of non-refusal as tentative support though. |
(As a further aside, I think it was probably a mistake in the original design of forms that disabled controls are not submitted. If it wasn't decades too late to reverse that decision, I'd call for reversing it. But I think having both modes with an explicit switch is worse than having just the inferior mode.) |
I wanted to say that I find this a compelling counterargument. Ideally what we should be seeing here is @ilisepe1 producing a library or framework plugin that gets wide adoption, before we put it in browsers. The wide adoption would prove not only that this is a problem lots of people have, but it would also prove that it's possible for a single simple solution to serve everyone's needs. The worst case would be finding out that the proposed "submitanyway" attribute only addresses some small fraction of the use cases that are cited in support of this issue, as then we've added a new feature to the platform for very little gain. |
Hello all, Since it was cited, I can't agree more with the first part of @othermaciej's last coment. I can't stress enough though that I disagree with the conclusion, because it's like saying "ok, I admit the problem, but let's not do anything to fix it". Anyway, I have to acknowledge it's very encouraging (to logic) that you at least consider committing to this feature. In my head, it makes perfect sense and surprises me why it's not already included, but enough with me grumbling. On the other hand, I never thought that you (whatwg) would tell me to get involved on this feature actively. So, if I understand correctly you ask me to dive into firefox code and implement this feature? However, I am willing to try as long as someone points me at least to the specific source files/folders that deal with this feature. Unless, you ask me to do something on top of it (ie with js), which sounds scary since I'll have to control things on a higher layer (ie dom) for things that a lower layer is responsible (browser). Looks like a bogus/bloated project. I'm open to ideas. Thank you |
That's not what at least I meant. What I meant is producing a JavaScript library that e.g. watches the DOM for any We can then see if your library gets a lot of usage, to find out if it's actually a widespread problem, and to find out if your proposed solution solves the problem for everyone. |
See also w3c/html#89 w3c/html#91 w3c/html#92 The use cases seem pretty clear, the question in terms of priority, as @othermaciej points out, is how often people are doing this. The problem is that without a straightforward solution, there are a number of different strategies, including:
Since all of these can be accomplished in multiple ways, that makes it very hard to find out how common they are. Adding another approach as a polyfill can provide a measurable quantification of uptake, but the delta is only those who find it and decide it is more convenient than to continue using one or other existing technique, so its a slow and extremely conservative way to learn anything. The question of web compatibility is also hard. Since unimplemented Newer implementations of input types also repeatedly seem to get readonly behaviour when shipped, and then get fixed later to match the spec. Since I assume browser developers are not obviously fools, this suggests that the idea of None of which answers the prioritisation question, so much as pointing out that the data is harder to read than it seems :( |
Hello all, After @domenic's suggestion, project created. It's just a draft yet, but it seems to be working. I hope there is support from the users, although I'm not sure how they will find it:) |
@domenic created a poll on twitter: 21% out of 318 answered "Yes". Some relevant comments: https://twitter.com/harmenjanssen/status/840097921894772739
https://twitter.com/medikoo/status/839941581520130050
https://twitter.com/tabatkins/status/839915334089990147
https://twitter.com/pracucci/status/839910665296961536
|
wow, 21% :) +1 to https://twitter.com/harmenjanssen/status/840097921894772739 and https://twitter.com/medikoo/status/839941581520130050 :) Perhaps you should tweet my little project to check responses? Just to update you, I also found another project similar to what we are discussing here: And another one (for select tags only): https://gist.github.com/jpetitcolas/4395080 |
Ok, I just wanted to share that there is another problem with disabled elements. Seems like you can't dispatch events to them. Probably this has nothing to do with you, or does it? |
Just ran into this problem in designing a Firefox extension options page. It is very unintuitive that checkboxes cannot be made read-only especially after one has done it with ARIA Furthermore, this issue is unexpectedly difficult to polyfill. Using the Add to that styling issues: if you want what one might call the "read-only appearance", then one has to disable the checkbox anyway thereby mooting the above fix. You can't create it yourself short of just replacing the element outright since browsers like Firefox don't allow one to style the checkbox border or content. I even tried CSS While read-only isn't strictly required for this use case, it seems to me to be good UI to disable options that that aren't relevant based on other options. There's no reason for a user to need to tab through a checkbox that doesn't matter, for example, and it makes the UI easier to understand at a glance since one's visual focus will move to the stuff that doesn't have the "read-only appearance". (In the case of my UI, I also gray-out irrelevant form control labels to improve readability.) Lastly, I think a |
I was very disappointed to see |
Apologies for jumping in late on this discussion, but: note that using ARIA, it is currently possible (and valid) to set |
I find it problematic that someone with higher permissions managed to subvert this issue away from discussion about There are real distinctions between read-only and disabled states that people have tried to voice, but it was muddied by this sidetrack into this tangentially-related proposal to mess with disabled input form submissions. "Disabled inputs that submit" is not a one-to-one equivalent to a read-only input, and dismissing read-only as some sort of inferior variant of disabled inputs is disingenous. Read-only is an input that is part of the form, but not editable. This could be a transitional state based on other factors. It is still a value in the form. Disabled is an input that is not available. While some visual appearances are similar (particularly for checkboxes/radios), they are not equivalent states. The underlying values that this form is managing is where the distinction between read-only or disabled is occuring. It is an attribute of the data management in the form, not the UI element it has currently been wired up to. It's frustrating that this is clearly a distinction that is important and permissible to text inputs, but for arbitrary reasons, this distinction is denied to every other input type. A lot of other form elements submit strings, just like text inputs, but those opposed to This handicap with the HTML spec / native inputs usually get bypassed by encapsulating the limited |
Hello,
As I understand, HTML "readonly" attribute applies only to text based form elements (ie text, textarea).
At least that's how firefox/chrome behaves.
Wouldn't it be nice to work on every form element ((multiple)selectbox, checkbox, radios, etc)?
(Just like the "disabled" attribute that works to all form elements.)
Thank you.
Ilias
The text was updated successfully, but these errors were encountered: