<%= 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

<% selected_resource = @command.associated_resources %> <%= render 'shared/resources_dropdown', field_id: 'command_resources', label_text: 'Devices / Device Tags / Network', placeholder: 'Type to select Devices / Devices Tags / Network', input_name: 'command[aps][]', resource_model: @command, selected_values: selected_resource, resource_types: 'network,device,tag', container_class: 'col-sm-8', label_class: 'col-sm-2 control-label', custom_class: 'commands', dropdown_width: '100%', validation_data: { 'validation' => 'required', 'validation-error-msg-container' => '#command_resource-error' } %>
<%=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 %>