Custom Content Form Field Object
item.getFields()
returns the array of Field object. The
Field object holds field data.
Method | Parameter | Required | Returns | Usage |
---|---|---|---|---|
field.getDefinition() |
None |
n/a |
Returns field
definition.
Settings property holds the field setting set for the field. Refer to Field Settings for more detail. |
|
field.getValue() |
None |
n/a |
Returns field value. Refer to Field Types and Values for details. |
|
field.getValueAt(index) |
index Non-negative number |
yes |
Returns field value at specified index. Works for multi-valued fields only. |
|
field.validate(value, options) |
value - value of the field options - optional |
yes | Validates given field value and returns a Promise. When
fulfills returns validation
object.
|
|
field.setValue(value, options) |
value - see section on field types and values options - object with |
no options - optional |
Sets given value for the field. When options with silent: true property is passed, form doesn't become dirty. |
|
field.setValueAt(index, value, options) |
index - Non-negative number options - object with |
index - yes options - optional |
Sets given value at the specified index for the field. Works only for multi-valued fields. When options with silent: true property is passed, form doesn't become dirty. |
|
field.removeValueAt(index, options) |
index - Non-negative number options - object with |
index - yes options - optional |
Removes value at the specified index. Works only for multi-valued fields. When options with silent: true property is passed, form doesn't become dirty. |
|
field.openAssetPicker(options) |
options - parameters to be sent to asset picker. Refer to options of mediaPicker and referencePicker sections in Embed UI API V2 for Oracle Content Management, a JavaScript API options - Object |
yes |
Opens the asset picker and returns a Promise. When
fulfilled returns an object containing id, name and type of the
selected
asset.
|
|
field.on(event, handler) |
event - string handler - function that handles the event |
yes |
Currently only 'update' event is supported. |
|
field.createCustomEditor(editorName, options) |
editorName - name of the custom field editor options - Object Can have index, width and height. index: If the field is multi-valued and the editor is needed to display field value for a specific index, then index can be passed. width and height: This method returns a CustomEditor object with the given custom field editor rendered in an iframe. If the iframe containing the field editor needs to be in a certain initial size, then the width and height parameters can be passed. Note: custom field editors can have their own fixed sizes. They might also trigger to adjust the containing frame's size.
|
editorName - yes options - optional |
Returns CustomEditor object |
|
Field Types and Values
Value parameter passed to field.setValue()
or the value
obtained from field.getValue()
varies depending on the field data
type and value count.
Datatype | Value count | Value | Sample value |
---|---|---|---|
text |
single list |
String Array of strings |
|
largetext |
single list |
String Array of strings |
|
reference |
single list |
Object with type, ID and name Array of objects with type, ID and name |
|
number |
single |
integer |
|
decimal |
single |
decimal |
|
boolean |
single |
true|false |
|
datetime |
single |
Object with value and timezone where value is the date string with format
and time zone is the timezone string |
|
json |
single |
json string |
|
Field Settings
Settings property holds the information about the settings of the field
including editor name and any field specific validators. Following is a sample
settings property for a multi-valued text data type with multi-select SelectBox
editor. Editor name set in the field definition can be obtained from
settings.caas.editor.name
. Available editors associated with
field types are listed under Field Types and Available Editors.
"settings": {
"groupIndex": 3,
"caas": {
"description": "Fruits list",
"valuecountRange": {
"min": 1,
"max": 3
},
"customValidators": [],
"editor": {
"name": "multi-selectbox",
"options": {
"multiple": true,
"valueOptions": [
{
"value": "apple",
"label": "apple"
},
{
"value": "banana",
"label": "banana"
},
{
"value": "orange",
"label": "orange"
}
]
}
}
}
}
Field Types and Available Editors
Data Type | Single | List |
---|---|---|
text |
textbox textarea radiobuttonset single-selectbox single-selectbox-rest |
textbox textarea checkboxset multi-selectbox multi-selectbox-rest tagcloud |
largetext |
textarea rich-text-editor markdown-editor |
textarea rich-text-editor markdown-editor |
number |
number-inc-dec radiobuttonset single-selectbox |
n/a |
decimal |
number-inc-dec radiobuttonset single-selectbox |
n/a |
boolean |
boolean-switch boolean-checkbox |
n/a |
datetime |
datepicker datetimepicker datetimepickerz |
n/a |
reference |
mediapicker (in case of media) itempicker |
mediapicker (in case of media) itempicker |
json |
json-form json-textarea |
n/a |