summaryrefslogtreecommitdiff
path: root/app/views/snippets/_form.html.haml
blob: b8d8c09849d45642f1f0c555d701cbc7d9743166 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%h3= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr
= form_for [@project, @snippet] do |f|
  %table.no-borders
    -if @snippet.errors.any?
      .alert-message.block-message.error
        %ul
          - @snippet.errors.full_messages.each do |msg|
            %li= msg

    .clearfix
      = f.label :title
      .input= f.text_field :title, placeholder: "Example Snippet"
    .clearfix
      = f.label :file_name
      .input= f.text_field :file_name, placeholder: "example.rb"
    .clearfix
      = f.label "Lifetime"
      .input= f.select :expires_at, lifetime_select_options, {}, style: "width:200px;"
    .clearfix
      = f.label :content, "Code"
      .input= f.text_area :content, class: "span8"

  .actions
    = f.submit 'Save', class: "primary btn"
    = link_to "Cancel", project_snippets_path(@project), class: " btn"
    - unless @snippet.new_record?
      .right= link_to 'Destroy', [@project, @snippet], confirm: 'Are you sure?', method: :delete, class: "btn right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}"



:javascript
  $(function(){
    $('select#snippet_expires_at').chosen();
  });