View Source Backpex.Fields.HasMany (Backpex v0.6.0)
A field for handling a has_many
or many_to_many
relation.
This field can not be orderable or searchable.
Options
:display_field
- The field of the relation to be used for searching, ordering and displaying values.:display_field_form
- Optional field to be used to display form values.:live_resource
- The live resource of the association. Used to generate links navigating to the associations.:options_query
- Manipulates the list of available options in the multi select. Defaults tofn (query, _field) -> query end
which returns all entries.:prompt
- The text to be displayed when no options are selected or function that receives the assigns. Defaults to "Select options...".:not_found_text
- The text to be displayed when no options are found. Defaults to "No options found".:live_resource
- Optional live resource module used to generate links to the corresponding show view for the item.:query_limit
- Optional limit passed to the query to fetch new items. Set tonil
to have no limit. Defaults to 10.
Example
@impl Backpex.LiveResource
def fields do
[
posts: %{
module: Backpex.Fields.HasMany,
label: "Posts",
display_field: :title,
options_query: &where(&1, [user], user.role == :admin),
live_resource: DemoWeb.PostLive
}
]
end