<% @action_for_layout_builder = action_name == 'edit' ? 'update' : 'create' %>
<%= form_for(@view_builder, :url => url_for(:controller => 'layout_builder', action: @action_for_layout_builder),  remote: true) do |form| %>
  <%= form.hidden_field :layout_id, value: params[:id] %>

  <div class="form-group">
    <h5 class="bold">Single Data View name</h5>
    <p>Add a new to easily reference the Single Data View</p>
    <%= form.text_field :view_name, class: 'form-control form-input' %>
  </div>

  <div class="form-group">
    <h5 class="bold">Primary table</h5>
    <p>Select the primary table that this layout will be based on.</p>
    <%= form.select :table_name,
                    options_for_select(@available_tables, selected: @view_builder.table_name),
                    { prompt: "Select a table" },
                    { class: 'form-control' , "data-table-name" =>  @view_builder.table_name, :disabled => true } %>
  </div>

  <div class="form-group">
    <div class="row flex">
      <div class="col-md-8">
        <h5 class="bold">Commentable</h5>
        <p>Users can add comments related to primary table.</p>
      </div>
      <div class="col-md-4 align-self-center">
        <label class="switch">
          <div class='toggle'>
            <%= form.check_box :commentable, class: 'form-control toggle-state' %>
            <div class='toggle-inner'>
               <div class='indicator'></div>
            </div>
            <div class='active-bg'></div>
          </div>
        </label>
      </div>
    </div>
  </div>

  <div class="form-group hide">
    <h5 class="bold">Parent comments table</h5>
    <p>Select a parent table if applicable. E.g. Companies might be parent to Users.</p>
    <%= form.select :parent_comment_table,
                    options_for_select(@available_tables, selected: @view_builder.parent_comment_table),
                    { prompt: "Select a table" },
                    { class: 'form-control' } %>
  </div>

  <div class="actions" style="text-align: right">
    <%= form.submit "Save", class: "btn btn-primary" %>
  </div>
<% end %>
