Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Exclude Bug with Fix #28

Description

@arkytn

An old bug has reappeared in v1.4.5. When you exclude fields from saving, it also removes them from the actual form. Your previous fix method of changing getFormData() to use $.extend() doesn't work now, at least in Chrome. The extend is doing a shallow copy so all the fields are by reference. Change the workingObject and theform changes as well. Even adding extend(true,{}, theform); didn't help.

I've rewritten it so it no longer needs cloning at all. Simpler filtering routine. Removes items from the save list without affecting the original form.

    /*
    * Serialize the form data, omit excluded fields marked with data-sayt-exclude attribute.
    */
    function getFormData(theform, excludeSelectors) {
      // almost all useable clone methods pass by reference
      // so I went to a filter style fix on the DOM elements.

      excludeSelectors.push('[data-sayt-exclude]'); // Add attribute selector to the list
      $elements = theform.find(':input[name]'); //All fields with names
      $elements = $elements.not(excludeSelectors.join()); //multi select
      var form_data = $elements.serializeArray();
      return form_data;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions