{hero}

fields.getFormatter

Since: Editor 2.0

Define a function that can transform a value being read from a field.
Please note - this property requires the Editor extension for DataTables.

The full Editor reference documentation is available to registered users of Editor - the information shown below is a summary only. If you already have an Editor license please , alternatively an Editor license can be purchased on this site, or sign up for the free trial.

Description

This option provides the ability to modify the data the end user inputs in an input element (or any other field type) transforming it into any other format before being used by the API or form submission. This can be useful for cases where you want the end user to not see the original data format.

Consider for example editing an ISO8601 date string - it isn't the friendliest format to show to your end users, so you might use fields.setFormatter to convert it to a more readable format (in combination with the datetime's format option to tell it what the format is) and then this option to convert it back to ISO8601 for the rest of your program. This use case is shown in the example below.

Note that although fields.getFormatter and fields.setFormatter are typically used together, it is not required.