Sha256: 78265db077f67fe098640f5fe4bc0139f18c073be7ede15b84b5e715bd463871

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

- field_options = options.slice(:id, :name, :placeholder)

.input{:class => [options[:type], options[:class]]}
  %label{:for => options[:id]} #{options[:label]}:
  - case options[:type].to_sym
    - when :textarea
      %textarea{:id => options[:id], :name => options[:name], :rows => options[:rows] || 20, :placeholder => options[:placeholder]}= html_escape(options[:value])

    - when :radio
      - options[:options].each do |o|
        .option
          %input{field_options.merge(:type => 'radio', :value => o, :checked => options[:value] == o)}= o

    - when :dropdown
      %select{field_options}
        - options[:options].each do |val, text|
          %option{:value => val, :selected => options[:value] == val}= text

    - when :datetime
      %input{field_options.merge(:value => options[:value].to_formatted_s(:db))}

    - when :boolean
      %input{field_options.merge(:type => 'hidden', :value => "0")}
      %input{field_options.merge(:type => 'checkbox', :value => "1", :checked => options[:value])}
      %span.value Enable

    - else # normal inputs
      %input{field_options.merge(:value => options[:value])}

  - if options[:errors]
    .error= options[:errors].join(", ")

  - if options[:hint]
    .hint= options[:hint]

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
schnitzelpress-0.2.1 lib/views/partials/_form_field.haml
schnitzelpress-0.2.0 lib/views/partials/_form_field.haml
schnitzelpress-0.1.1 lib/views/partials/_form_field.haml
schnitzelpress-0.1.0 lib/views/partials/_form_field.haml