Module: Formz::Wrappers
- Defined in:
- lib/formz/wrappers.rb
Overview
Formz::Wrappers
The Formz:Wrappers module wraps input, textarea and select tags with wrapping div elements to aid in styling.
Examples
tag :input, :type => :file, :name => :upload
<div class="field-upload field-file">
<input type="file" name="upload" />
</div>
Constant Summary collapse
- WRAP_TAGS =
:input, :textarea, :select
Instance Method Summary collapse
Instance Method Details
#create_tag(name, contents, attrs, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/formz/wrappers.rb', line 23 def create_tag name, contents, attrs, &block if name.in? WRAP_TAGS classes = "field-#{attrs[:name].to_s.gsub('[', '-').gsub(']', '')}" classes.add_class "field-#{attrs[:type]}" if :type.in? attrs classes.add_class 'field' Tagz.tag :div, super, :class => classes else super end end |