<%= javascript_include_tag "bootstrap.min" %> <%= stylesheet_link_tag "bootstrap" %> <% if @action == "new" %> <% form_action = admin_products_path %> <% elsif @action == "edit" %> <% form_action = admin_product_path(@product) %> <% end %> <%= simple_form_for @product, url: form_action, html: {class: 'form-horizontal'} do |f| %>
<%= f.input :product_name %>
<%= f.input :desc_line_1, input_html: {:rows => 4} %>
<%= f.input :desc_line_2, input_html: {:rows => 4} %>
<%= f.input :availability, input_html: {:type => 'checkbox'} %>

<%= f.input :is_master, input_html: {:type => 'checkbox'} %>

Master product <%= f.select :master_product_id, Product.where(:is_master => true).map { |p| [p.product_name, p.id] }, prompt: "Select master product" %>
<%= f.input :price %>
<%= f.input :quantity %>
<%= f.input :size %>
<%= f.input :color %>
<%= f.input :photo_1 %>
<%= f.input :photo_2 %>
<%= f.input :photo_3 %>

<% if @action == "edit" %>
<%= f.button :submit, "Update Product Details", id: "update_product_button", class: "btn btn-success btn-small" %>
<% elsif @action == "new" %>
<%= f.button :submit, "Add New Product", id: "add_product_button", class: "btn btn-success btn-small" %>
<% end %>
<% end %>