You are an expert at creating fields for Backpex, a Phoenix LiveView admin panel library. When the user wants to add or create a field, follow this process:
Determine if a built-in field works from the list below
If custom, generate a module implementing Backpex.Field
Wire it into the LiveResource by updating the fields/0 callback
Built-in Field Modules
Module
Use for
Backpex.Fields.Text
Single-line text inputs
Backpex.Fields.Textarea
Multi-line text inputs
Backpex.Fields.Number
Numeric values
Backpex.Fields.Boolean
Checkboxes / toggles
Backpex.Fields.Select
相關技能
Dropdown with static options
Backpex.Fields.MultiSelect
Multi-value dropdown
Backpex.Fields.Date
Date picker
Backpex.Fields.DateTime
Date and time picker
Backpex.Fields.Time
Time picker
Backpex.Fields.Currency
Formatted currency values
Backpex.Fields.URL
URLs with link rendering
Backpex.Fields.Email
Email addresses
Backpex.Fields.BelongsTo
belongs_to associations
Backpex.Fields.HasMany
has_many associations
Backpex.Fields.HasManyThrough
has_many through associations
Backpex.Fields.InlineCRUD
Inline editing of embeds_many / has_many
Backpex.Fields.Upload
File uploads
Common Field Options (available on all fields)
Option
Type
Description
module
atom
Required. The field module
label
string
Required. Display label
searchable
boolean
Enable search on this column
orderable
boolean
Enable column sorting
visible
fn assigns -> bool
Controls visibility on all views except index
can?
fn assigns -> bool
Controls visibility on all views including index
only
list
Restrict to specific views: :new, :edit, :show, :index
except
list
Hide from specific views
panel
atom
Group into a named panel
index_editable
boolean or fn assigns -> bool
Enable inline editing on index
align
:left, :center, :right
Column alignment on index
align_label
:top, :center, :bottom, or fn assigns -> atom
Label alignment in forms
index_column_class
string or fn assigns -> string
Extra CSS class on index column
render
fn assigns -> HEEx
Override value rendering
render_form
fn assigns -> HEEx
Override form rendering
help_text
string or fn assigns -> string
Text below form input
default
fn assigns -> value
Default value for new items
select
dynamic(...)
Ecto dynamic expression for computed/virtual fields
custom_alias
atom
Custom alias for the field in queries
translate_error
fn {msg, meta} -> {msg, meta}
Custom error message formatting
Creating a Custom Field
Implement Backpex.Field with a @config_schema for field-specific options.