Move HasErrors to helpers.
This commit is contained in:
parent
a4655ba845
commit
3387cc7066
|
@ -6,7 +6,6 @@ module SimpleForm
|
|||
autoload :Components, 'simple_form/components'
|
||||
autoload :ErrorNotification, 'simple_form/error_notification'
|
||||
autoload :FormBuilder, 'simple_form/form_builder'
|
||||
autoload :HasErrors, 'simple_form/has_errors'
|
||||
autoload :Helpers, 'simple_form/helpers'
|
||||
autoload :I18nCache, 'simple_form/i18n_cache'
|
||||
autoload :Inputs, 'simple_form/inputs'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module SimpleForm
|
||||
module Components
|
||||
module Errors
|
||||
include SimpleForm::HasErrors
|
||||
include SimpleForm::Helpers::HasErrors
|
||||
|
||||
def error
|
||||
template.content_tag(error_tag, error_text, error_html_options) if has_errors?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module SimpleForm
|
||||
class ErrorNotification
|
||||
delegate :object, :object_name, :template, :to => :@builder
|
||||
include SimpleForm::HasErrors
|
||||
include SimpleForm::Helpers::HasErrors
|
||||
|
||||
def initialize(builder, options)
|
||||
@builder = builder
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
module SimpleForm
|
||||
module HasErrors
|
||||
|
||||
protected
|
||||
|
||||
def errors
|
||||
object.errors
|
||||
end
|
||||
|
||||
def has_errors?
|
||||
object && object.respond_to?(:errors) && errors.present?
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
module SimpleForm
|
||||
module Helpers
|
||||
autoload :HasErrors, 'simple_form/helpers/has_errors'
|
||||
autoload :Maxlength, 'simple_form/helpers/maxlength'
|
||||
autoload :Pattern, 'simple_form/helpers/pattern'
|
||||
autoload :Validators, 'simple_form/helpers/validators'
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
module SimpleForm
|
||||
module Helpers
|
||||
module HasErrors
|
||||
private
|
||||
|
||||
def errors
|
||||
object.errors
|
||||
end
|
||||
|
||||
def has_errors?
|
||||
object && object.respond_to?(:errors) && errors.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue