Class

Field

Field()

Class representing a field from Contentstack UI. Only available for Custom Field extension
Constructor

# new Field()

View Source field.ts, line 28

Members

string

# data_type

The data type of the current field is set using this method.

View Source field.ts, line 50

Object

# schema

The schema of the current field (schema of fields such as ‘Single Line Textbox’, ‘Number’, and so on) is set using this method.

View Source field.ts, line 56

string

# uid

The UID of the current field is defined in the content type of the entry.

View Source field.ts, line 45

string

# uid

View Source field.ts, line 150

Methods

# getData(options) → {Object|string|number}

Gets the data of the current field
Parameters:
Name Type Description
options Object Options object for get Data method.
resolved boolean If the resolved parameter is set to true for the File field, then the method will return a resolved asset object along with all the field metadata, e.g. 'field.getData({resolved:true})'.

View Source field.ts, line 165

Returns the field data.
Object | string | number

# onChange(callback)

This function is called when another extension programmatically changes data of this field using field.setData() function, only available for extension field, only support extensions of data type text, number, boolean or date.
Parameters:
Name Type Description
callback function The function to be called when an entry is published.

View Source field.ts, line 177

# setData(data) → {external:Promise}

Sets the data for the current field.
Parameters:
Name Type Description
data Object | string | number Data to be set on the field

View Source field.ts, line 157

A promise object which is resolved when data is set for a field. Note: The data set by this function will only be saved when user saves the entry.
external:Promise

# setFocus() → {Object}

Sets the focus for a field when an extension is being used. This method shows user presence and highlights the extension field that the user is currently accessing in Contentstack UI.

View Source field.ts, line 171

A promise object which is resolved when Contentstack UI returns an acknowledgement of the focused state.
Object