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

Uploading empty form fields #131

Closed
dalamberts opened this issue Jan 15, 2015 · 2 comments
Closed

Uploading empty form fields #131

dalamberts opened this issue Jan 15, 2015 · 2 comments

Comments

@dalamberts
Copy link

When I post a standard HTML form it adds all form fields into _POST even if they are empty. The plugin only sends fields with data. Can an option be added such as uploadEmptyExtraData: true that would mirror the standard HTML form post?

@kartik-v
Copy link
Owner

The plugin does not understand what all you need to submit.

You (the developer) needs to set all form variables OR any additional variables in uploadExtraData. This will be submitted via $_POST. You can also set uploadExtraData as a callback.

@dalamberts
Copy link
Author

If I set:
uploadExtraData: { first_name: 'Kartik', middle_initial: '', last_name: ' Visweswaran'},

The plugin passes only the first_name and last_name fields because the middle_initial is an empty string.

If I had a basic HTML form that did not use this plugin, and filled out the form the same way, I would receive all 3 fields in the $_POST variable and the $_POST[ 'middle_initial' ] will contain an empty string.

The plugin will not send any form elements who value is an empty string in uploadExtraData, see code below from fileinput.js starting on line 862
uploadExtra: function(fd) {
var self = this, data = self.getExtraData();
if (data.length == 0) {
return;
}
$.each(data, function(key, value) {
if (!isEmpty(key) && !isEmpty(value)) { // THIS IS WHERE IT BLOCKS ALL EMPTY FIELDS
fd.append(key, value); // FROM BEING ADDED TO $_POST
}
});
},

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

No branches or pull requests

2 participants