Field
A Field object represents one field instance on a form. This is different from the general idea of a field type; here, you are working with the actual field that is being rendered, inspected or processed.
Properties
The ID of this use of the field on a form. Submissions and browser code use this ID; definitionId identifies the shared field settings.
The form-field instance UID. Copies and new imports receive new instance UIDs.
The database ID of the field’s shared settings, called its definition internally. Synced fields share this value. It is not a key for reading submission values.
The unique identifier (UID) of the field’s shared settings. Stencils and form imports use it to preserve synced field relationships across environments.
The field label.
The field handle.
The stable field reference, when available.
The field type.
The Form this field belongs to.
Whether the field is required.
Whether the field is enabled.
The field instructions.
The field placeholder, where supported.
The field default value, where supported.
The field settings.
Methods
The methods below help you render fields and read their values. For implementing storage and value handling in your own field type, see Custom Field.
Returns whether the field should render a label.
Returns the field’s HTML id value.
Returns the field’s HTML name value.
Returns attributes for the field container.
Returns attributes for the field input, where applicable.
Returns the field's input HTML. This omits the surrounding label, validation rules and error container. Use craft.formie.renderField(form, field) when custom rendering needs a complete field.
Returns the field’s reference-block HTML.
Returns the parent field for sub-fields and nested fields.
Sets the parent field for sub-fields and nested fields.
Returns a string representation of a submitted value.
Returns data that can be encoded as JSON: a single value for simple fields, or named parts or selected records for more complex fields.
Returns the value prepared for export.
Returns a single readable value for a report cell, including report exports. Call field.getValueForReport(value, submission, useOptionLabels) with the normalized field value and its submission. The optional useOptionLabels argument defaults to true; pass false to use stored option values. The default implementation uses the field's string representation. Fields can customize report output independently of structured export data.
Fields implementing verbb\formie\base\ReportSubfieldsInterface can also provide direct child columns through getReportSubfields(). See Report Subcolumns for the opt-in contract.
Returns the value prepared for summary views.
Returns the value prepared for singular reference contexts.
Returns the value prepared for reference-block rendering.