mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
Use the fancy disable API.
This commit is contained in:
parent
ba6bbac56c
commit
c640fb542e
3 changed files with 10 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue