Sha256: 8354a0388be289a7a2cf90302f4718d414ff6111f7009731dddc19078c588f6b
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
- type = attributes.delete(:type) - attributes[:value] ||= model.send(field) || default - if help_text - attributes[:'aria-describedby'] = "#{attributes[:id]}_helptext" - if type == 'hidden' %input{attributes, type: type, value: model.send(field) || default} - else .form-group - if type != 'file' %label{ for: attributes[:id] }= label - if type == 'select' - options = attributes.delete(:options) - value = attributes.delete(:value) - if attributes[:multiple] - attributes[:name] = "#{attributes[:name]}[]" unless attributes[:name][-2..-1] == '[]' %select{attributes} - if attributes[:multiple] - options.each do |k, v| k = v if k.nil?; v = k if v.nil?; %option{ value: k.to_s, selected: value&.include?(k) }= v - else %option{ value: "" } -- Select One -- - options.each do |k, v| k = v if k.nil?; v = k if v.nil?; %option{ value: k.to_s, selected: value == k }= v - elsif type == 'textarea' %textarea{attributes}= preserve(model.send(field) || default) - else %input{ attributes, type: type } - if model.errors[field] .invalid-feedback= model.errors[field].join(', ') - if help_text %small.form-text.text-muted{ id: "#{attributes[:id]}_helptext" }= help_text
Version data entries
5 entries across 5 versions & 1 rubygems