module JqueryUiForm module Helpers module ErrorHelper def has_errors?(method) @object && @object.respond_to?(:errors) && !@object.errors[method.to_sym].blank? end def error_message_on(method) @object.errors[method.to_sym].join(" #{use_i18n ? I18n.t('and') : 'and'} ") end def error_messages_on_base @object.errors[:base].join(" #{use_i18n ? I18n.t('and') : 'and'} ") end def inline_error(method) return "" unless has_errors?(method) template.content_tag(:div, error_message_on(method), :class => "ui-input-error-message") end def model_errors(errors=[]) errors = error_messages_on_base.to_a + errors.to_a return "" if errors.empty? template.content_tag(:div, :class => "ui-base-error-messages") do errors.each do |message| template.concat( template.content_tag(:p) do template.concat(template.content_tag(:span, "", :class => "ui-icon ui-icon-alert")) template.concat(template.content_tag(:strong, message)) end ) end end end end end end