For update form with params?

I'm wondering, when using for_update on an existing resource, do I need to explicitly make a params map? I was expecting it'd be auto populated. Even when I did Map.take/2 on the resource and put that as params it didn't work because params expect string keys. Am I missing something or is this expected? 🤔
8 Replies
ZachDaniel
ZachDaniel4mo ago
You shouldn't need to it should automatically show those existing values when using the standard patterns
ken-kost
ken-kostOP4mo ago
hmm, okay, thought so. guess I'm missing something, I'll figure it out 👍 currently did
form =
AshPhoenix.Form.for_update(record, :update)
|> to_form()
form =
AshPhoenix.Form.for_update(record, :update)
|> to_form()
guess that's wrong I tried the Tunez approach, i.e. adding extension AshPhoenix to my resource and using form_to_update but still it doesn't show existing values 🤔 might be a fluxon thing :S
sevenseacat
sevenseacat4mo ago
nope, that's fine what does your form look like? what does your action look like?
ken-kost
ken-kostOP4mo ago
just an update: 😗 update: :* and I have a define :update
sevenseacat
sevenseacat4mo ago
does the resource have public attributes? they're the only ones that will show up on the form
ken-kost
ken-kostOP4mo ago
yes, they are public. like I said, might be a fluxon_ui thing? maybe it just looks in params
sevenseacat
sevenseacat4mo ago
without seeing any code, hard to say
ken-kost
ken-kostOP4mo ago
<.form
:let={f}
class="grid grid-rows-3 grid-cols-1 items-center justify-center"
for={@my_form}
id="my_form"
phx-submit="submit"
phx-change="change"
>
<.form
:let={f}
class="grid grid-rows-3 grid-cols-1 items-center justify-center"
for={@my_form}
id="my_form"
phx-submit="submit"
phx-change="change"
>
and in it for example:
<.date_picker
field={f["start_date"]}
label={gettext("Start Date")}
placeholder={gettext("Select a date")}
description={gettext("When will you travel?")}
/>
<.date_picker
field={f["start_date"]}
label={gettext("Start Date")}
placeholder={gettext("Select a date")}
description={gettext("When will you travel?")}
/>
form = MyApp.MyResource.form_to_update(my_record) |> to_form() let me just check the fluxon code I guess it's a fluxon thing, nothing else comes to mind 🤷

Did you find this page helpful?