Use the fancy disable API.

This commit is contained in:
José Valim 2011-09-03 13:01:41 +02:00
parent ba6bbac56c
commit c640fb542e
3 changed files with 10 additions and 12 deletions

View File

@ -5,6 +5,10 @@ module SimpleForm
enabled_error
end
def has_errors?
object && object.respond_to?(:errors) && errors.present?
end
protected
def enabled_error
@ -15,10 +19,6 @@ module SimpleForm
nil
end
def has_errors?
object && object.respond_to?(:errors) && errors.present?
end
def error_text
if options[:error_prefix]
options[:error_prefix] + " " + errors.send(error_method)

View File

@ -5,10 +5,14 @@ module SimpleForm
nil # This component is disabled by default.
end
def has_placeholder?
options[:placeholder] != false && placeholder_text.present?
end
private
def enabled_placeholder
input_html_options[:placeholder] ||= placeholder_text if placeholder_present?
input_html_options[:placeholder] ||= placeholder_text if has_placeholder?
nil
end
@ -16,10 +20,6 @@ module SimpleForm
nil
end
def placeholder_present?
options[:placeholder] != false && placeholder_text.present?
end
def placeholder_text
@placeholder_text ||= options[:placeholder] || translate(:placeholders)
end

View File

@ -1,9 +1,7 @@
module SimpleForm
module Inputs
class HiddenInput < Base
def label; "" end
def error; end
def hint; end
disable :label, :error, :hint
def input
@builder.hidden_field(attribute_name, input_html_options)