scripts:field-value-formats

Field value formats

Form field values can be represented by an object, a string, or a number. This applies both to reading (obtaining values via FormState) and writing (returning a new field value).

Type Reading Writing
Text,
Email,
Telephone
{
  text: "value"
}
{
  text: "new value"
}
or
"new value"
Number,
Money
{
  value: 10
}
or (in the case of table fields)
{
  value: 10,
  sum: 50
}
{
  value: 42
}
or
42
Multiple choice
{
  choice_id: 1,
  choice_name: "Yes"
}
{
  choice_id: 1
}
or
{
  choice_name: "Yes"
}
Due date
{
  date: "2020-01-01"
}
{
  date: "2020-01-05"
}
or
{
  days_from_create: 10
}
Due date and time
{
  value: Date
}
{
  date: "2020-01-05T10:30:00Z"
}
or
{
  hours_from_create: 10
}
Catalog
{
  item_id: 123,
  columns: {
    "column name": "value"
  }
}
or

{
  values: [
    {
      item_id: 123,
      columns: {
        "column name": "value for 123"
      }
    },
    {
      item_id: 129,
      columns: {
        "column name": "value for 129"
      }
    } 
  ]
}
  
{
  item_name: "Value from the first column of the catalog"
}
or
{
  values: [
    {
      item_name: 'Lemon'
    },
    {
      item_name: 'Kiwi'
    }
  ]
}

Was this article helpful?

Yes, thanks! No, I have a question