Belongs To
Runway provides a dedicated fieldtype to managebelongsTo
relationships within Statamic.
Templating
In Antlers, you can access any of the fields on the model. They’ll be augmented using the resource’s blueprint.Options
Option | Description |
---|---|
mode | Set the UI style for this field. Can be one of ‘default’ (Stack Selector), ‘select’ (Select Dropdown) or ‘typeahead’ (Typeahead Field). |
resource | Specify the Runway Resource to be used for this field. |
relationship_name | The name of the Eloquent Relationship this field should use. When left empty, Runway will attempt to guess it based on the field’s handle. |
create | By default you may create new models. Set to false to only allow selecting from existing models. |
with | Specify any relationships you want to be eager loaded when this field is augmented. This option accepts an array of relationships. |
title_format | Configure the title format used for displaying results in the fieldtype. You can use Antlers to pull in model data. |
query-scopes | Allows you to specify a query scope which should be applied when retrieving selectable models. You should specify the query scope’s handle, which is usually the name of the class in snake case. For example: MyAwesomeScope would be my_awesome_scope . |
Has Many
Runway provides a dedicated fieldtype to managehasMany
relationships within Statamic.
Templating
Loop through the models and do anything you want with the data.Options
Option | Description |
---|---|
mode | Set the UI style for this field. Can be one of ‘default’ (Stack Selector), ‘select’ (Select Dropdown) or ‘typeahead’ (Typeahead Field). |
resource | Specify the Runway Resource to be used for this field. |
relationship_name | The name of the Eloquent Relationship this field should use. When left empty, Runway will attempt to guess it based on the field’s handle. |
create | By default you may create new models. Set to false to only allow selecting from existing models. |
with | Specify any relationships you want to be eager loaded when this field is augmented. This option accepts an array of relationships. |
title_format | Configure the title format used for displaying results in the fieldtype. You can use Antlers to pull in model data. |
reorderable | Determines whether the models can be reordered. Defaults to false . |
order_column | When reordering is enabled, this determines which column should be used for storing the sort order. When the relationship uses a pivot table, the order column must exist on the pivot table. |
query-scopes | Allows you to specify a query scope which should be applied when retrieving selectable models. You should specify the query scope’s handle, which is usually the name of the class in snake case. For example: MyAwesomeScope would be my_awesome_scope . |
Belongs To Many
The Has Many fieldtype is also compatible withbelongsToMany
relationships. You can use the Has Many fieldtype on both sides of the relationship.