Change to delete empty name field

This commit is contained in:
kPherox 2019-08-25 07:04:46 +09:00
parent 705b5adfc4
commit b15e226593
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
1 changed files with 9 additions and 2 deletions

View File

@ -144,8 +144,15 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do
|> Enum.dedup()
params =
if Map.has_key?(params, "fields_attributes") && Enum.all?(params["fields_attributes"], &is_tuple/1) do
Map.update!(params, "fields_attributes", &Enum.map(&1, fn {_, v} -> v end))
if Map.has_key?(params, "fields_attributes") do
Map.update!(params, "fields_attributes", fn fields ->
if Enum.all?(fields, &is_tuple/1) do
Enum.map(fields, fn {_, v} -> v end)
else
fields
end
|> Enum.filter(fn %{"name" => n} -> n != "" end)
end)
else
params
end