Skip to content

Commit b117187

Browse files
committed
fix: properly retain values for fallback rendered attribute inputs
fixes #361
1 parent 10de547 commit b117187

File tree

1 file changed

+10
-3
lines changed
  • lib/ash_admin/components/resource

1 file changed

+10
-3
lines changed

lib/ash_admin/components/resource/form.ex

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ defmodule AshAdmin.Components.Resource.Form do
14031403
<.input
14041404
type={text_input_type(@form.source.resource, @attribute)}
14051405
placeholder={placeholder(@attribute.default)}
1406-
value={@value}
1406+
value={value(@value, @form, @attribute, @attribute.default)}
14071407
name={@name || @form.name <> "[#{@attribute.name}]"}
14081408
id={@id || @form.id <> "_#{@attribute.name}"}
14091409
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
@@ -1419,7 +1419,7 @@ defmodule AshAdmin.Components.Resource.Form do
14191419
<.input
14201420
type={text_input_type(@form.source.resource, @attribute)}
14211421
placeholder={placeholder(@attribute.default)}
1422-
value={@value}
1422+
value={value(@value, @form, @attribute, @attribute.default)}
14231423
name={@name || @form.name <> "[#{@attribute.name}]"}
14241424
id={@id || @form.id <> "_#{@attribute.name}"}
14251425
class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md"
@@ -1862,12 +1862,19 @@ defmodule AshAdmin.Components.Resource.Form do
18621862
|> replace_new_union_stubs()
18631863
|> replace_unused()
18641864

1865+
IO.inspect(params)
1866+
18651867
form =
18661868
AshPhoenix.Form.validate(socket.assigns.form, params,
18671869
only_touched?: true,
1868-
target: event["_target"] || []
1870+
target: IO.inspect(event["_target"] || [])
18691871
)
18701872

1873+
IO.inspect(AshPhoenix.Form.errors(form, for_path: :all))
1874+
IO.inspect(AshPhoenix.Form.value(form, :size))
1875+
IO.inspect(AshPhoenix.Form.value(form, :name))
1876+
IO.inspect(AshPhoenix.Form.value(form, :balance))
1877+
18711878
{:noreply, assign(socket, form: form)}
18721879
end
18731880

0 commit comments

Comments
 (0)