Commit 26c3c1cb authored by David Johnson's avatar David Johnson
Browse files

Fix default-true checkbox parameter handling in wizard.

If the profile's default value of a boolean (checkbox) parameter is
true, currently, the ppwizardstart code does not return a false or ""
value if the user unselects the checkbox.  This is because of how
jQuery's serializeArray() serializes form values (it only serializes
"successful" values, which include only checked input checkboxes, not
unchecked checkboxes).  So, we add those values back in the response to
the server (instead of sending "checked" for a checked box, we send ""
-- and this gets correctly interpreted by the python backend).
parent d496c294
......@@ -665,9 +665,18 @@ $(function () {
// Convert form data into formfields array, like all our
// form handler pages expect.
var fields = $('#pp_form').serializeArray();
console.info("fields", fields);
$.each(fields, function(i, field) {
formfields[field.name] = field.value;
});
// Add back any unchecked inputs with "" values, since
// serializeArray() does not include un"successful" elements
// (see https://api.jquery.com/serializeArray/ and
// https://www.w3.org/TR/html401/interact/forms.html#h-17.13.2)
var input_fields = $('#pp_form').closest('form').find("input:checkbox:not(:checked)");
$.each(input_fields,function(i,field) {
formfields[field.name] = "";
});
// This clears any errors before new submit. Needs more thought.
GenerateModalBody(formfields, null);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment