Fields ​
- Type
- Class
- Namespace
- craft\web\twig\variables
- Inherits
- craft\web\twig\variables\Fields
- Since
- 3.0.0
- Deprecated in
- in 3.0.0
Fields provides an API for accessing information about fields. It is accessible from templates via craft.fields
.
Public Methods ​
Method | Description |
---|---|
getAllFieldTypes() | Returns all available field type classes. |
getAllFields() | Returns all fields. |
getAllGroups() | Returns all field groups. |
getFieldByHandle() | Returns a field by its handle. |
getFieldById() | Returns a field by its ID. |
getFieldsByGroupId() | Returns all the fields in a given group. |
getGroupById() | Returns a field group by its ID. |
getLayoutById() | Returns a field layout by its ID. |
getLayoutByType() | Returns a field layout by its associated element type. |
getAllFieldTypes()
​
Returns all available field type classes.
Returns ​
string[] – The available field type classes
getAllFields()
​
Returns all fields.
Arguments ​
Returns ​
craft\base\FieldInterface[] – The fields
getAllGroups()
​
Returns all field groups.
Arguments ​
Returns ​
craft\models\FieldGroup[] – The field groups
getFieldByHandle()
​
Returns a field by its handle.
Arguments ​
$handle
(string) – The field’s handle
Returns ​
craft\base\FieldInterface, null – The field, or null if it doesn’t exist
getFieldById()
​
Returns a field by its ID.
Arguments ​
$fieldId
(integer) – The field’s ID
Returns ​
craft\base\FieldInterface, null – The field, or null if it doesn’t exist
getFieldsByGroupId()
​
Returns all the fields in a given group.
Arguments ​
$groupId
(integer) – The field group’s ID$indexBy
(string, null) – The attribute to index the fields by
Returns ​
craft\base\FieldInterface[] – The fields
getGroupById()
​
Returns a field group by its ID.
Arguments ​
$groupId
(integer) – The field group’s ID
Returns ​
craft\models\FieldGroup, null – The field group, or null if it doesn’t exist
getLayoutById()
​
Returns a field layout by its ID.
Arguments ​
$layoutId
(integer) – The field layout’s ID
Returns ​
craft\models\FieldLayout, null – The field layout, or null if it doesn’t exist
getLayoutByType()
​
Returns a field layout by its associated element type.
Arguments ​
$type
(string) – The associated element type
Returns ​
craft\models\FieldLayout – The field layout