Model Selector
The Model Selector enables users to select a model from a pop up list. Selectors allow admin to select items from a list of options. Sometimes, the collected value is an ID but the display is different (it might be a title or an icon or a combination of things)
Example 1
This model selector is configured to allow the user to select a post of type 'news'. The post slug is collected.
<x-textstem::inputs.model-selector
name="model-selector"
value=""
label="Model Selector"
source="posts"
collectKey="slug"
itemTemplate="${item.title} "
type="news"
readonly
></x-textstem::inputs.model-selector>
Select posts:news
Example 2
This model selector is configured with a more detailed item template
<x-textstem::inputs.model-selector
name="model-selector2"
value=""
label="Model Selector2"
source="posts"
collectKey="title"
itemTemplate="
${item.title}
<div class='text-slate-500'>
${item.slug} [id ${item.id}]
</div> "
type="news"
readonly></x-textstem::inputs.model-selector>
Select posts:news
Options
| Option | Description |
|---|---|
source |
The source defines the 'objectlist' class used to retrieve a list of models. Textstem comes with objectlists for assets, pages, posts and users. Custom objectlists can be added to your App\Domain\Admin\Objectlist directory |
type |
Optional parameter that is passed with source (default is empty) |
collectKey |
Which property of the model to collect. Default is id |
itemTemplate |
Template for displaying each model in the pop-up list. The default is ${item.title} |
See Also
- Asset Selector
- Page Selector
- User Selector