backbone.jsmarionettesyphon

Syphon serializes disabled fields


Looks like Syphon is currently serializing every form field regardless of its state. Is there a way to easily tell Syphon to not serialize disabled fields?


Solution

  • Standard form submit does not include disabled fields and neither does JQuery serialize() method.

    Since my primary concern was with disabled checkboxes getting serialized I was able to stop it from serializing those by adding this validator:

    Backbone.Syphon.KeyAssignmentValidators.register("checkbox", function ($el, key, value) {
        return $el.prop("checked") && $el.is(":enabled");
    });
    

    Note: this is a global change and effects all views.