Hello,
I need to toggle disabled attribute on an input field and have the following code:
def is_disabled(true, attrs), do: [{:disabled, true} | attrs]
def is_disabled(_, attrs), do: attrs
<%= form_for :price_form, "#", [phx_change: :price_change], fn f -> %>
<%= text_input f, :price, is_disabled(true, [value: @total_price]) %>
The input field will be shown correctly - it will be disabled and the toggling will work. The problem is however that in the appropriate callback function, the form will just ignore that input field:
def handle_event("price_change", params, socket) do
IO.inspect params["price_form"]
The IO.inspect
shows the following:
%{
"comment" => "",
"invoicing_entity" => "1",
}
All input fields are shown except for the :price
one.
I confirmed that when I take out the toggling part, everything works fine.
Any help is highly appreciated!