<% load_ace_editor! %> <% if @agent.errors.any? %>

<%= pluralize(@agent.errors.count, "error") %> prohibited this Agent from being saved:

<% @agent.errors.full_messages.each do |msg| %>

<%= msg %>

<% end %>
<% end %> <%= form_for(@agent, as: :agent, url: @agent.new_record? ? agents_path : agent_path(@agent), method: @agent.new_record? ? "POST" : "PUT", html: { class: 'agent-form' }) do |f| %> <%= hidden_field_tag :return, params[:return] %>
<% if @agent.new_record? %>
<%= f.label :type %> <%= f.select :type, options_for_select(agent_type_select_options, @agent.type), {}, class: 'form-control', autofocus: true %>
<% end %>
<%= f.label :name %> <%= f.text_field :name, :class => 'form-control' %>
<%= render partial: 'oauth_dropdown', locals: { agent: @agent } %>
<%= f.label :schedule, :class => 'control-label' %>
<%= f.select :schedule, options_for_select(Agent::SCHEDULES.map {|s| [builtin_schedule_name(s), s] }, @agent.schedule), {}, :class => 'form-control' %>
This type of Agent cannot be scheduled.
<%= f.label :controllers %> <%= f.select(:controller_ids, options_for_select(current_user.agents.select(&:can_control_other_agents?).pluck(:name, :id), @agent.controller_ids), {}, { multiple: true, size: 5, class: 'select2-linked-tags form-control', data: {url_prefix: '/agents'}}) %>
<%= f.label :sources %>
<%= f.label :receivers %>
<% if current_user.scenario_count > 0 %>
<%= f.label :scenarios %> <%= f.select(:scenario_ids, options_for_select(current_user.scenarios.pluck(:name, :id), @agent.scenario_ids), {}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/scenarios'} }) %>
<% end %>
<%= render partial: 'options', locals: { agent: @agent } %>
<%= @agent.html_description unless @agent.new_record? %>
<% end %>