Skip to content

Support "serialize" createField option #303

@kettanaito

Description

@kettanaito

What

Support serialize property on the field record.

Why

To have a field-specific custom serialization transformer. To deprive the necessity to carry around Form.props.onSerialize for the fields that are meant to have the same serialization transformer.

Specification

  1. A field may have a custom onSerialize property upon its creation in the options passed to createField high-order component.
  2. There is no serialize option set by default.
  3. Custom serialize has the highest priority, and is executed when serializing the fields.
  4. Whenever a form-wide Form.props.onSerialize and a field-wide serialize are present, the form's transformer accepts already transformed field serialized value.

How

  • Add the serialize property to the createField options
  • Grab the serialize from the field record upon dispatching fieldUtils.serializeFields
  • Add unit test that custom serialize transformer gets propagated to the field record upon creation
  • Add integration test to assert custom serialize transformer is dispatched when a form is serialized
  • Add integration test to assert that custom serialize and Form.props.onSerialize complement each other
  • Update createField options documentation (+ example of usage)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions