mirror of
https://github.com/ash-project/ash_phoenix.git
synced 2024-09-20 07:12:49 +12:00
improvement: remove unknown keys option from embedded attributes
docs: update upgrade docs to reflect change of skip_unknown_attributes
This commit is contained in:
parent
8fb8b6aaf0
commit
c526768670
3 changed files with 5 additions and 17 deletions
|
@ -4,8 +4,6 @@ There are a few major changes in 3.0 that you should be aware of that affect Ash
|
||||||
|
|
||||||
1. You don't need to pass in the `domain` to your forms.
|
1. You don't need to pass in the `domain` to your forms.
|
||||||
|
|
||||||
~~2. Extra inputs are no longer accepted by actions. This means that if you were using custom form parameters, you may run into issues. There is a new option when constructing forms, `skip_unknown_inputs: ["foo", "bar"]` that allows you to skip these, but they don't currently apply to nested forms. If you need this, or encounter any issues, please open an issue.~~
|
~~2. When calling `AshPhoenix.Form.params/1`, for the same reasons as above, it will no longer return the hidden fields from the form. If you need these, you can add the `hidden?: true` option to `AshPhoenix.Form.params/1`.~~
|
||||||
|
|
||||||
~~3. When calling `AshPhoenix.Form.params/1`, for the same reasons as above, it will no longer return the hidden fields from the form. If you need these, you can add the `hidden?: true` option to `AshPhoenix.Form.params/1`.~~
|
|
||||||
|
|
||||||
The above items were worked around, and are no longer true
|
The above items were worked around, and are no longer true
|
||||||
|
|
|
@ -151,20 +151,13 @@ defmodule AshPhoenix.Form.Auto do
|
||||||
end
|
end
|
||||||
|
|
||||||
updater = fn opts, data, params ->
|
updater = fn opts, data, params ->
|
||||||
{type, constraints, tag} = determine_type(constraints, data, params)
|
{type, constraints, _tag} = determine_type(constraints, data, params)
|
||||||
|
|
||||||
{embed, constraints, fake_embedded?, skip_unknown_inputs} =
|
{embed, constraints, fake_embedded?} =
|
||||||
if Ash.Type.embedded_type?(type) do
|
if Ash.Type.embedded_type?(type) do
|
||||||
skip_unknown_inputs =
|
{type, constraints, false}
|
||||||
if tag do
|
|
||||||
[tag, to_string(tag)]
|
|
||||||
else
|
else
|
||||||
[]
|
{AshPhoenix.Form.WrappedValue, [], true}
|
||||||
end
|
|
||||||
|
|
||||||
{type, constraints, false, skip_unknown_inputs}
|
|
||||||
else
|
|
||||||
{AshPhoenix.Form.WrappedValue, [], true, []}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
prepare_source =
|
prepare_source =
|
||||||
|
@ -211,7 +204,6 @@ defmodule AshPhoenix.Form.Auto do
|
||||||
update_action: update_action.name,
|
update_action: update_action.name,
|
||||||
prepare_source: prepare_source,
|
prepare_source: prepare_source,
|
||||||
transform_params: transform_params,
|
transform_params: transform_params,
|
||||||
skip_unknown_inputs: skip_unknown_inputs,
|
|
||||||
embed?: true,
|
embed?: true,
|
||||||
forms: [],
|
forms: [],
|
||||||
updater: fn opts ->
|
updater: fn opts ->
|
||||||
|
|
|
@ -1796,11 +1796,9 @@ defmodule AshPhoenix.FormTest do
|
||||||
resource: Post,
|
resource: Post,
|
||||||
update_action: :update,
|
update_action: :update,
|
||||||
create_action: :create,
|
create_action: :create,
|
||||||
skip_unknown_inputs: ["id"],
|
|
||||||
forms: [
|
forms: [
|
||||||
comments: [
|
comments: [
|
||||||
data: & &1.comments,
|
data: & &1.comments,
|
||||||
skip_unknown_inputs: ["id"],
|
|
||||||
type: :list,
|
type: :list,
|
||||||
resource: Comment,
|
resource: Comment,
|
||||||
update_action: :update,
|
update_action: :update,
|
||||||
|
|
Loading…
Reference in a new issue