
<div id='<%= (f.object.key || 'new_lookup_keys').to_s.gsub(' ','_')%>' class='tab-pane fields' >
  <% is_param = f.object.is_param %>

  <%= text_f(f, :environment_classes, :value => f.object.environment_classes.map(&:environment).to_sentence, :label=> _('Puppet Environments'), :disabled=>true) if is_param%>

  <%= remove_child_link(_("Remove %s?") % (f.object.new_record? ? _("Variable") : f.object), f , {:class => 'btn btn-danger hide'}) unless controller_name == "lookup_keys" %>
  <%= text_f f, :key, :disabled => f.object.is_param %>
  <%= f.hidden_field :key if is_param %>
  <%= textarea_f f, :description, :rows => :auto %>

  <%= show_puppet_class f %>
  <%= checkbox_f(f, :override, :onchange=>'toggleOverrideValue(this)',
                 :help_block => _("Whether the smart-variable should override the Puppet class default value.")
      ) if is_param%>

  <%= param_type_selector f  %>
  <%= textarea_f f, :default_value, :value => f.object.default_value_before_type_cast , :disabled => (f.object.is_param && !f.object.override), :rows => :auto,
                 :help_block => _("Value to use when there is no match") %>
  <div <%= "id=#{(f.object.key || 'new_lookup_keys').to_s.gsub(' ','_')}_lookup_key_override_value" %> style=<%= "display:none;" if (f.object.is_param && !f.object.override) %>>
    <legend>Optional Input Validator</legend>
    <%= checkbox_f(f, :required, :disabled => !f.object.override,
                   :help_block => _("If checked, will raise an error if there is no default value and no matcher provide a value.")
        ) if is_param %>
    <%= validator_type_selector f  %>
    <%= text_f f, :validator_rule, :disabled => f.object.validator_type.blank? %>

    <legend>Override Value For Specific Hosts</legend>
    <%= textarea_f f, :path, :rows => :auto, :label => _("Order"), :value => f.object.path,
                   :help_block => popover(_("The order in which values are resolved"),
                                          _("The order in which matchers keys are processed, first match wins.<br> You may use multiple attributes as a matcher key, for example, an order of <code>host group, environment</code> would expect a matcher such as <code>hostgroup = \"web servers\", environment = production</code>"), :title => _("The order in which values are resolved")).html_safe
    %>

    <div class="children_fields">
      <%= new_child_fields_template(f, :lookup_values, {:partial => "lookup_keys/value"}) %>
      <%= f.fields_for :lookup_values do |lookup_values| %>
          <%= render 'lookup_keys/value', :f => lookup_values %>
      <% end %>
      <%= add_child_link '+ ' + _("Add Matcher-Value"), :lookup_values, { :title => _('add a new matcher-value pair')} %>
    </div>
  </div>
</div>
