Sha256: 475f9c4d5c6e05147aa475689fb3dcf75dc9d3fcf5e4fc570a9cb6ebdd6ebbc8

Contents?: true

Size: 917 Bytes

Versions: 14

Compression:

Stored size: 917 Bytes

Contents

%div{ class: "form-group#{model.errors[field] ? ' has-error' : ''}" }
  %label.col-sm-3.control-label{ for: attributes[:id] }= label
  .col-sm-9
    - type = attributes.delete(:type)
    - if type == 'select'
      - options = attributes.delete(:options)
      %select{attributes}
        - if attributes[:multiple]
          - options.each do |k,v| k ||= v;  v ||= k;
            %option{ value: k, selected: (model.send(field).map(&:id).include? k)}= v
        - else
          %option{ value: ""} -- Select One --
          - options.each do |k,v| k ||= v;  v ||= k;
            %option{ value: k, selected: [model[field].to_s, default].include?(k.to_s)}= v
    - elsif type == 'textarea'
      %textarea{attributes}= preserve(model[field])
    - else
      %input{attributes, type: type, value: model[field] || default}
    - if model.errors[field]
      %p.help-block.text-danger= model.errors[field].join(', ')

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ditty-0.7.2 views/partials/form_control.haml
ditty-0.7.1 views/partials/form_control.haml
ditty-0.7.0 views/partials/form_control.haml
ditty-0.7.0.pre.rc1 views/partials/form_control.haml
ditty-0.6.0 views/partials/form_control.haml
ditty-0.4.1 views/partials/form_control.haml
ditty-0.4.0 views/partials/form_control.haml
ditty-0.3.3 views/partials/form_control.haml
ditty-0.3.2 views/partials/form_control.haml
ditty-0.3.1 views/partials/form_control.haml
ditty-0.3.0 views/partials/form_control.haml
ditty-0.2.2 views/partials/form_control.haml
ditty-0.2.1 views/partials/form_control.haml
ditty-0.2.0 views/partials/form_control.haml