UserFrosting
UserFrosting copied to clipboard
ufForm uses the largely unsupported `set` FormData method.
As documented at MDN, full support for FormData is rare among browsers. This includes the set
method used in ufForm. An alternative should be implemented, that gets executed instead if feature detection reveals that the required function is missing.
@x00x70 can you look in to this?
i can look, but am completely stacked right now
No rush!
So i've looked into this. in its current form it might not be easy to implement. Edge, IE 10 and Safari do not have FormData methods beyond append()
and hence cannot access/modify the underlying data in the object. Options:
- re-implement this for every browser
- add another function for just unsupported browsers (and browser detecton. seems ugly)
- wait for browsers to catch up.
- the
set()
function is the only thing we use which is not supported. We use the set function for handling the binary check boxes. If we re-implement how we capture checkbox input for binary values, then we no longer need theset()
function. This might be a good start: https://stackoverflow.com/a/20570060/7335809
When i originally implemented the formData object, it was to enable image upload via ajax. re-implementing this without a formData object might be a difficult challenge, as i seem to recall i used the formData objects for a reason.
thoughts?
Does library like Dropzone use formData
to process uploads? If they do, they probably don't support checkbox anyway and won't be of any help, but if they don't use formData, then they must use something else to handle uploads...
That, or handle checkbox the traditional way php side ? :smiling_imp:
Another way could be to append each form input to an empty formData
?
See: https://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax
It looks like .set
is only used for the binaryCheckboxes
feature anyway, right? I'd like to refactor this aspect of ufForm
anyway, since right now we have binaryCheckboxes
implemented in two different places.
I'd also like to generalize binaryCheckboxes
to some kind of transform
API as well, while we're at it.
There does appear to be a polyfill, but I'm not sure how it's supposed to work client-side without Node.
Actually, we may be able to solve this problem (and many others) simply by having ufForm
as a wrapper around jQuery Form Plugin
's ajaxSubmit
method.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Still an issue I think?
Well, support for FormData
in evergreen browsers has improved substantially since this issue was created. Working on this should only be necessary to support older browsers (e.g. IE11, which MS has since given an expiration date).
Ok. There are still other reasons for rewriting/redesigning ufForm
at some point. I'm not so sure about jQuery Form right now though, because apparently it's not fully compatible with jQuery 3 at the moment. It might be a situation where we can simultaneously rewrite ufForm
and contribute to jQuery Form at the same time...
Evidently they'd appreciate the help: https://github.com/jquery-form/form#pull-requests-needed