%= form_for(@gamification_plugin_badge, :url => {:action => @gamification_plugin_badge.new_record? ? :create : :update, :id => @gamification_plugin_badge.id }) do |f| %>
<% if @gamification_plugin_badge.errors.any? %>
<%= pluralize(@gamification_plugin_badge.errors.count, "error") %> prohibited this gamification_plugin_badge from being saved:
<% @gamification_plugin_badge.errors.full_messages.each do |msg| %>
- <%= msg %>
<% end %>
<% end %>
<% rules = Merit::BadgeRules::AVAILABLE_RULES %>
<% rules.merge! Merit::BadgeRules::CONFERENCE_RULES if defined? Merit::BadgeRules::CONFERENCE_RULES %>
<%= f.label :name %>
<%= f.select :name, rules.map{ |key, rule| key } %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.label :level %>
<%= f.text_field :level %>
<%= _('Actions') %>
<%= f.fields_for :custom_fields do |c| %>
<% rules.each do |name, settings| %>
<% settings.each do |setting| %>
<%= c.label _(setting[:action]) %>
<%= c.fields_for setting[:action] do |d| %>
<% action = (@gamification_plugin_badge.custom_fields || {}).fetch(setting[:action], {}) %>
<%= d.label :threshold %>
<%= d.text_field :threshold, {value: action.fetch('threshold', "")} %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= f.submit %>
<% end %>