Skip to main content

Serializable label fields

Serializable labels work exactly the same as normal labels except they also serialize to XML. They should only be used if you are editing the content of a label programmatically, and wish it to serialize to XML.

Serializable label field

A block with the serializable label "a serializable label". Visually, this is
no different from a block with a normal
label.

Serializable label field on a collapsed block

The same block after being collapsed. It has the label "a serializable label"
and a jagged right edge to show it is
collapsed.

Creation

{
"type": "example_serializable_label",
"message0": "%1",
"args0": [
{
"type": "field_label_serializable",
"name": "FIELDNAME",
"text": "a serializable label"
}
]
}

The serializable label field takes in an optional value, and an optional css class string. Both default to an empty string.

Serialization

The JSON for a serializable label field looks like so:

{
"fields": {
"FIELDNAME": text
}
}

Where FIELDNAME is a string referencing a serializable label field, and the value is the value to apply to the field. The value follows the same rules as the constructor value.

Validators

Serializable label fields do not support validators, because they are not editable by a user.