When we are using as
like this:
<.simple_form for={%{}} as={:tag} phx-submit="save_tag" phx-change="validate_tag">
We should get it in our handle_event
like this, okay?
def handle_event(
"save_tag",
{"tag" => %{"tag" => tag, "type" => type, "id" => id, "parent_id" => parent_id}},
socket
) do
But I got:
def handle_event(
"save_tag",
%{"tag" => tag, "type" => type, "id" => id, "parent_id" => parent_id},
socket
) do
Am I wrong in understanding as
keyword?
It should be noted, I updated my mix file to phoenix 1.7 and after that I copied the core_components.ex
from a fresh phoenix 1.7 installed
Other problem is, why we should pass value to input
, when it is empty by default
<.input name="tag" label="Tag Name" id={"field-tag-#{@type}-#{@block_id}"} value=""/>
without value=""
I have error, I can edit the core component or create new one to have this, but I am curious why it should be like this, Something like this is my preference
attr :value, :any, default: nil // or , default: ""
...
value={Phoenix.HTML.Form.normalize_value(@type, @value)}