<div class="fields">
  <%= field_set_tag _("Interface").html_safe + " #{remove_child_link('x', f, { :rel => 'twipsy', "data-title" => _('remove network interface'), :'data-placement' => 'left',
                                                             :class => 'fr badge badge-danger'})}".html_safe, :id => "interface" do %>
    <%= selectable_f f, :type, [[_("Interface"), Nic::Managed],[_("BMC"), Nic::BMC]], {}, :class => 'interface_type', :disabled => !f.object.new_record? %>
    <%= text_f f, :mac %>
    <%= text_f f, :name, :help_inline => _("DNS name") %>
    <%= select_f f, :domain_id, accessible_domains, :id, :to_label,
                 { :include_blank => accessible_domains.any? ? true : _("No domains")},
                 { :disabled => accessible_domains.empty? ? true : false,
                   :help_inline => :indicator,
                   :class => 'interface_domain', :'data-url' => domain_selected_hosts_path } %>
    <% domain = f.object.respond_to?(:domain) ? f.object.domain : nil %>
    <%= select_f f, :subnet_id, domain_subnets(domain), :id, :title,
                 { :include_blank => domain_subnets(domain).any? ? true : _("No subnets")},
                 { :disabled => domain_subnets(domain).empty? ? true : false,
                   :help_inline => :indicator,
                   :class => 'interface_subnet', :'data-url' => freeip_subnets_path } %>
    <%= text_f f, :ip  %>

    <%# hack to get BMC attributes show up without AJAX %>
    <%= content_tag :span, :id => 'bmc_fields', :class => f.object.is_a?(Nic::BMC) ? '' : 'hide' do %>
      <%= text_f f, :username, ifs_bmc_opts(f.object) %>
      <%= password_f f, :password, ifs_bmc_opts(f.object) %>
      <%# TODO: current rails version does not allow to pass a selected value where there is no method (e.g. providers below) rescue here is a hack %>
      <%= selectable_f f, :provider, Nic::BMC::PROVIDERS, {:selected => nil}, ifs_bmc_opts(f.object) rescue f.hidden_field :provider, :value => 'IPMI' %>
    <% end %>

  <% end %>
</div>

