-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Set hidden input’s name using visible input - and remove visible input’s name #377
Comments
After thinking a bit more about this, I now think we should go a step further: Just remove the |
True..well now that you mentioned that, nothing really needs to be changed at all. You can simply remove the hidden suffix and prefix by setting them to an empty string - thereby making both input fields use the same name. The last named value is what gets sent to the server, which will always be the hidden input since that appears after the visible input in the DOM. |
Although you are basically right and this is the way I am currently doing it already; this seems to be semantically wrong. Actually - as far as I know - both values will be send to the server, but usual servers will overwrite previous field-values if the same field-name occurs twice. So: yes, no urgent action needed. But from a semantical point of view I would prefer to remove the name= from the non-data-relevant input. |
Sorry, you're right - both values are still sent, but yes servers usually do remedy duplicate names by resolving to the last value. And yeah, you are right about it not being a totally appropriate solution to the issue. So I'm going to reopen and add an option to cut the input's name onto the hidden one instead. I'd assume the expected behavior is that setting that option to |
yes cool, agreed on that |
I have 2 date pickers (from and until). They are both required. I'm using the "required" html5 attribute for both display inputs but since the datepicker removed the 'name' attribute, the required validation only works in the first picker. not both. Is there any alternative for this scenario to work? |
Nice solution, seems a better solution than the hidden prefixes/suffixes. Could this please become the default? I can imagine this makes it harder to upgrade, but new people with ruby/rails seem to keep running into this issue because root problem is unclear, see also veracross/pickadate-rails#13 (comment) |
Say we have the following minimal form:
Adding datepicker will extend this form like this:
This forces the server-side to be kind of aware of pickadate. It also does not allow progressive enhancement. IMHO the form should be more like:
In order to not break current behavior, adding an option 'displaySuffix' and 'displayPrefix' would be an idea.
Also it would be cool when then suffix would respect array notation. In a rails app i usually have input names like:
Appending the suffix like this:
breaks the form. Prefereable would be
Should I implement those features and drop in a pull-request?
The text was updated successfully, but these errors were encountered: