fix: Make styled inputs work correctly

This commit is contained in:
Robert Prehn 2021-09-17 11:42:20 -05:00
parent 75e1422708
commit 6937fd5365

View file

@ -48,7 +48,7 @@ defmodule Legendary.CoreWeb.Helpers do
{type, rest_opts} = Keyword.pop(opts, :type, input_type(f, field)) {type, rest_opts} = Keyword.pop(opts, :type, input_type(f, field))
{classes, rest_opts} = Keyword.pop(rest_opts, :class, default_classes_for_type(type)) {classes, rest_opts} = Keyword.pop(rest_opts, :class, default_classes_for_type(type))
{label_text, rest_opts} = Keyword.pop(rest_opts, :label) {label_text, rest_opts} = Keyword.pop(rest_opts, :label)
{input_helper, _rest_opts} = Keyword.pop(rest_opts, :input_helper, type) {input_helper, _rest_opts} = Keyword.pop(rest_opts, :input_helper, input_type(f, field))
error_classes = error_classes =
if Keyword.get_values(f.errors, field) |> Enum.any?() do if Keyword.get_values(f.errors, field) |> Enum.any?() do
@ -103,7 +103,7 @@ defmodule Legendary.CoreWeb.Helpers do
~E""" ~E"""
<%= content_tag :div, class: Enum.join([classes, error_classes], " ") do %> <%= content_tag :div, class: Enum.join([classes, error_classes], " ") do %>
<%= apply(Phoenix.HTML.Form, input_helper, [f, field, rest_opts ++ child_opts]) %> <%= apply(Phoenix.HTML.Form, type, [f, field, rest_opts ++ child_opts]) %>
<% end %> <% end %>
""" """
end end