Skip to content
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

Missing empty values #38

Open
pnikolov opened this issue Oct 8, 2014 · 3 comments
Open

Missing empty values #38

pnikolov opened this issue Oct 8, 2014 · 3 comments
Milestone

Comments

@pnikolov
Copy link
Contributor

pnikolov commented Oct 8, 2014

How to reproduce
Use the following demo - http://jsfiddle.net/9xfdvLbL/

Conditions
Typing some copy in the input text and by selecting one or more categories, you get:

{"filtering":{"title":"john doe","categories":["1","3"]}}

Problem
When submitting the form without entering any values in the form fields. You get:

{"filtering":{"title":""}}

Expectation
When submitting the form with no values in the fields to get:

{"filtering":{"title":"","categories":[]}}
@macek
Copy link
Owner

macek commented Oct 8, 2014

This is a current problem with jQuery.serializeArray

Using your code provided in your fiddle, the value of the text input is an empty string

$("input[type=text]").val()
// => ""

And the value of the select is null

$("select").val();
// => null

Now the issue with this is how jQuery.serialize is implemented. null values will be filtered out, but empty strings will not. That explains why the input value is included in the result but the select value is not.


I'm currently working on the 3.x version of this plugin that will no longer depend on the problematic jQuery.serializeArray. It has been a sore spot for many of the features we wish to support and so it's going to be replaced.

However, this may or may not solve your problem depending on how it gets implemented. 3.x's goal is to implement the W3C HTML JSON form submission spec as discussed in #24. How we choose to serialize empty values is yet to be decided.

I'll follow up here with any progress we make on this issue.

@macek macek added this to the 3.x milestone Oct 8, 2014
@ameshkin
Copy link

ameshkin commented Dec 2, 2016

I am having an issue with names like this not being recognized.

seatmap_options[calendar][g_1-8][1-8_extra5]

Any ideas what's wrong? The fields are just ignored

@ameshkin
Copy link

ameshkin commented Dec 2, 2016

The fields aren't validating for whatever reason. Not sure if it's a bug or not, or if the jquery plugin doesn't like my overly complex array in the name attribute.

I was able to comment out the validation line and it works fine now. Thank you for this. I wrote a simpler version years ago that didn't work as well with 3d arrays. This one does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants