smc/grandham

View on GitHub
app/views/books/_form.html.haml

Summary

Maintainability
Test Coverage
= simple_form_for @book, html: { class: 'form-horizontal' }, multipart: true do |f|
  %fieldset
    %legend= 'Add new book'
    .control-group
      = f.label :state_id, 'Language', class: 'control-label'
      .controls#region
        = f.collection_select :language_id, Language.all, :id, :name

    = f.input :title, as: :string, input_html: { class: 'input-xxlarge' }
    = f.fields_for :authors do |author_form|
      = author_form.input :name, as: :string, input_html: { class: 'input-xxlarge' }, label: 'Author'

    = f.fields_for :publishers do |publisher_form|
      = publisher_form.input :name, as: :string, input_html: { class: 'input-xxlarge' }, label: 'Publisher'

    = f.fields_for :libraries do |library_form|
      = library_form.input :name, as: :string, input_html: { class: 'input-xxlarge' }, label: 'Library'

    = f.input :isbn, as: :string, input_html: { class: 'input-xxlarge' }, label: 'ISBN'
    = f.input :year, as: :string, input_html: { class: 'input-xxlarge' }
    = f.input :pages, as: :string, input_html: { class: 'input-xxlarge' }
    = f.input :edition, as: :string, input_html: { class: 'input-xxlarge' }
    = f.input :description, as: :text, input_html: { rows: 5, cols: 50, class: 'input-xxlarge' }

    = f.fields_for :covers do |cover_form|
      .control-group
        = cover_form.label :image, 'Book cover', class: 'control-label'
        .controls
          = cover_form.file_field :image

    .form-actions
      = f.submit 'Submit', class: 'btn btn-primary'
      = link_to 'Cancel', root_path, class: 'btn'