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
Type: string|int|null
The ID of this use of the field on a form. Submissions and browser code use this ID; definitionId identifies the shared field settings.
Type: string|null
The form-field instance UID. Copies and new imports receive new instance UIDs.
Type: int|null
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.
Type: string|null
The unique identifier (UID) of the field’s shared settings. Stencils and form imports use it to preserve synced field relationships across environments.
Type: string|null
The field label.
Type: string|null
The field handle.
Type: string|null
The stable field reference, when available.
Type: string
The field type.
Type: verbb\formie\elements\Form|null
The Form this field belongs to.
Type: bool
Whether the field is required.
Type: bool
Whether the field is enabled.
Type: verbb\formie\models\RichText
The field instructions.
Type: string|null
The field placeholder, where supported.
Type: mixed
The field default value, where supported.
Type: array
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: bool
Returns whether the field should render a label.
Returns: string
Returns the field’s HTML id value.
Returns: string
Returns the field’s HTML name value.
Returns: array
Returns attributes for the field container.
Returns: array
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: string|bool|null
Returns the field’s reference-block HTML.
Returns: verbb\formie\base\FieldInterface|null
Returns the parent field for sub-fields and nested fields.
Sets the parent field for sub-fields and nested fields.
Returns: mixed
Returns a string representation of a submitted value.
Returns: mixed
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: mixed
Returns the value prepared for export.
Returns: mixed
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: mixed
Returns the value prepared for summary views.
Returns: mixed
Returns the value prepared for singular reference contexts.
Returns: mixed
Returns the value prepared for reference-block rendering.