diff --git a/lib/philomena_web/templates/profile/award/_form.html.slime b/lib/philomena_web/templates/profile/award/_form.html.slime index d1bf4e85..cdaf2627 100644 --- a/lib/philomena_web/templates/profile/award/_form.html.slime +++ b/lib/philomena_web/templates/profile/award/_form.html.slime @@ -1,16 +1,18 @@ = form_for @changeset, @action, fn f -> + - badge_options = badge_options(@badges) + = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. .field => label f, :badge_id, "Badge type" - = select f, :badge_id, badge_options(@badges), class: "input", data: [change_selectvalue: "#award_label"] + = select f, :badge_id, badge_options, class: "input", data: [change_selectvalue: "#award_label"] = error_tag f, :badge_id .field => label f, :label, "Label (Public)" - = text_input f, :label, class: "input input--wide" + = text_input f, :label, class: "input input--wide", value: first_badge_label(badge_options) = error_tag f, :label .field diff --git a/lib/philomena_web/views/profile/award_view.ex b/lib/philomena_web/views/profile/award_view.ex index 61215dec..b62ec138 100644 --- a/lib/philomena_web/views/profile/award_view.ex +++ b/lib/philomena_web/views/profile/award_view.ex @@ -10,4 +10,12 @@ defmodule PhilomenaWeb.Profile.AwardView do ] end end + + def first_badge_label([]) do + nil + end + + def first_badge_label([badge | _rest]) do + badge[:data][:set_value] + end end