Skip to content

New options: include and exclude elements with filter functions

Latest
Compare
Choose a tag to compare
@FThompson FThompson released this 01 Feb 19:12
· 1 commit to master since this release
17327ca

Added includeFilter and excludeFilter options to all functions:

  • includeFilter Define a whitelist filter function that inputs an element and outputs a Boolean. The element is included if the function returns true. This option must be a function that accepts an element parameter. This filter does not apply to any elements specially handled in valueFunctions.
  • excludeFilter Define a blacklist filter function that inputs an element and outputs a Boolean. The element is excluded if the function returns true. This option must be a function that accepts an element parameter. This filter does not apply to any elements specially handled in valueFunctions. Exclusions take precedence over inclusions.

For example, the following option excludes hidden fields:

FormPersistence.persist(form, { excludeFilter: element => element.type === 'hidden' });

Alternatively, the following option includes all non-hidden fields:

FormPersistence.persist(form, { includeFilter: element => element.type !== 'hidden' });