Module: Merb::Helpers::Form::Builder::Errorifier

Included in:
FormWithErrors, ResourcefulFormWithErrors
Defined in:
merb-helpers/lib/merb-helpers/form/builder.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) error_messages_for(obj, error_class, build_li, header, before)



407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'merb-helpers/lib/merb-helpers/form/builder.rb', line 407

def error_messages_for(obj, error_class, build_li, header, before)
  obj ||= @obj
  return "" unless obj.respond_to?(:errors)

  errors = obj.errors

  return "" if errors.empty?

  header_message = header % [errors.size, errors.size == 1 ? "" : "s"]
  markup = %Q{<div class='#{error_class}'>#{header_message}<ul>}
  errors.each {|err| markup << (build_li % err.join(" "))}
  markup << %Q{</ul></div>}
end