Upgrading to v0.14
View SourceBump Your Deps
Update Backpex to the latest version:
defp deps do
[
{:backpex, "~> 0.14.0"}
]
end
Filter callback functions have been changed
We now pass the assigns to the query
and options
filter callbacks. Therefore, the arity of these functions has changed.
Backpex.Filter.query/3
->Backpex.Filter.query/4
Backpex.Filters.Boolean.options/0
->Backpex.Filters.Boolean.options/1
Backpex.Filters.MultiSelect.options/0
->Backpex.Filters.MultiSelect.options/1
Backpex.Filters.Select.options/0
->Backpex.Filters.Select.options/1
If you have implemented any of the above callbacks, make sure to change your filters.
Before:
defmodule MyAppWeb.Filters.PostPublished do
use Backpex.Filters.Boolean
@impl Backpex.Filter
def label, do: "Published?"
@impl Backpex.Filters.Boolean
def options do
[
...
]
end
end
After:
defmodule MyAppWeb.Filters.PostPublished do
use Backpex.Filters.Boolean
@impl Backpex.Filter
def label, do: "Published?"
@impl Backpex.Filters.Boolean
def options(_assigns) do
[
...
]
end
end
input/1
component has been updated
We've updated the Backpex.HTML.Form.input/1
component:
input_wrapper_class
attribute has been removed as it was used by the select input only- new
error
class attribute to provide an error class to user over the defaults legend
element was replaced bydiv
element to align with Phoenix CoreComponents
If you use the input/1
make sure to update your code to accommodate these breaking changes, particularly removing any references to the deprecated input_wrapper_class
attribute.
Item Actions with form require changeset/3
callback
All item actions that define fields (basically all item actions with a form) must also implement Backpex.ItemAction.changeset/3
. This is necessary for validating and casting the parameters received from the form.
@impl Backpex.ItemAction
def changeset(change, attrs, _metadata) do
change
|> Ecto.Changeset.cast(attrs, [:field1, :field2])
|> Ecto.Changeset.validate_required([:field1])
end
render_form_readonly/1
callback has been removed
We removed the render_form_readonly/1
callback from fields. Instead, readonly
must be handled directly in the Backpex.Field.render_form/1
callback.
Make sure to update your custom fields accordingly. The readonly
value will be available in the assigns, which will be true
or false
.
@impl Backpex.Field
def render_form(%{readonly: true} = assigns) do
# Render readonly field
end
def render_form(%{readonly: false} = assigns) do
# Render editable field
end
See the Readonly guide for more details.