javascript:

var crudifier = new Rear.CRUD(#{item_id}, '#{self[:crud]}', '#{self[:edit]}', #{readonly? ? true : false});

.row-fluid

.span8

  form.form-horizontal#editor-main_form
    ul.nav.nav-tabs
      li.active
        a href="#editor-tabs-generic" data-toggle="tab"
          i.icon-edit
          |  
          = __rear__.label || __rear__.default_label

      - assocs(:belongs_to).each_key do |a|
        li
          a href="#editor-tabs-#{a}" data-toggle="tab"
            i.icon-tags
            |  
            = a

      - if item_id > 0
        - assocs(:has_one, :has_many).each_key do |a|
          li
            a href="#editor-tabs-#{a}" data-toggle="tab"
              i.icon-tags
              |  
              = a
      li
        a href=route(:edit, 0)
          span.badge.badge-warning
            i.icon-plus
            |  New

      - if item_id > 0
        li
          a onclick="if(confirm('This action can not be undone! Continue?')) { crudifier.delete('#{{route(pager_params)}}') } else { return false }" href="#"
            span.badge.badge-important
              i.icon-remove
              |  Delete

      li
        a.saveButton onclick="crudifier.save();" href="javascript:void(null);"
          span.badge.badge-success#editor-save_badge
            i.icon-check
            |  Save

    .tab-content style="min-height: 50em;"
      .tab-pane.active#editor-tabs-generic

        - rowed_columns = []
        - editor_columns.each do |column|
          - next if rowed_columns.include?(column.__id__)
          - if column.row?
            - if column.row.is_a?(String)
              .row-fluid
                .span style="text-align: center;"
                  h4.muted
                    = column.row

            .row-fluid
              - columns = editor_columns.select {|c| c.row == column.row}
              - columns.each do |rc|
                - self.column = rc
                - rowed_columns << rc.__id__
                div class=('span%s' % (12 / columns.size).ceil)
                  .editor-column_container title=rc.label
                    .editor-column_value
                      == render_editor_column rc

          - else
            - self.column = column
            .editor-column_container title=column.label
              .editor-column_value
                == render_editor_column column

      == reander_p 'editor/assocs', assoc_type: :belongs_to
      - if item_id > 0
        - [:has_one, :has_many].each do |type|
          == reander_p 'editor/assocs', assoc_type: type

  hr
  .row-fluid
    .pull-right
      a.btn.saveButton onclick="crudifier.save();" style="width: 10em;"
        i.icon-check
        | &nbsp;Save

.span4
  #editor-navigation.hide_under_940px
  javascript:
    $(function(){
      $.ajax({
        type: 'GET',
        url: '#{{route :quickview, pager_params.merge(selected: item_id.to_s)}}'
      }).done(function(response){ $('#editor-navigation').html(response) });
    });