<%= form_for command , as: :command, method: command.new_record? ? :post : :put, html: { class: "form-horizontal commands-form" , role: "form"} do |f| %>

Setup <% if params[:init] == "true" %>Init <% end %>Payload

<%=f.label :aps, "AP / Network / AP Tags", :class=>"col-sm-2 control-label"%>
<%= f.select :aps, grouped_options_for_select(grouped_collection_of_ap_and_networks_and_tags, { selected: @command.associated_resources}), {}, :multiple => true, :class=>"form-control associated-resource", :placeholder=>"Type to select APs / AP Tags / Network", :data => { validation: 'required'} %>
<%=f.label :commands, "Commands", :class=>"col-sm-2 control-label"%>
<%= f.text_field :commands, :class=>"form-control", :placeholder=>"Commands", :data => { validation: 'required'} %> <% if params[:init] %> <%= f.hidden_field :init, value: params[:init] %> <% end %>
<% if @command.blank? || @command.id.blank? %> <%= f.submit "Create " + (params[:init] == "true" ? "Init " : "") + "Payload", :class=>"btn btn-success commands-submit-btn" %> <% else %> <%= f.submit "Edit Payload", :class=>"btn btn-success commands-submit-btn" %> <% end %> <%= link_to "Cancel", commands_path, :class => "btn btn-primary" %>
<% end %>