Module: Formz::Errors
- Defined in:
- lib/formz/errors.rb
Overview
Formz::Errors
Adds classes and error messages when :error is present for any field.
Examples
password :password, :label => 'Password', :error => 'Invalid Password'
<div class="field-password">
<label for="password">Password:</label>
<input name="password" class="error" type="password" value="" />
<span class="error-message">Invalid Password</span>
</div>
Instance Method Summary collapse
- #create_tag(name, contents, attrs, &block) ⇒ Object
-
#form_errors ⇒ Object
Array of form specific errors.
Instance Method Details
#create_tag(name, contents, attrs, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/formz/errors.rb', line 30 def create_tag name, contents, attrs, &block if error = attrs.delete(:error) form_errors << error (attrs[:class] ||= '').add_class 'error' super << Tagz.tag(:span, error, :class => 'error-message') else super end end |
#form_errors ⇒ Object
Array of form specific errors.
26 27 28 |
# File 'lib/formz/errors.rb', line 26 def form_errors @__form_errors ||= [] end |