26 lines
586 B
Ruby
26 lines
586 B
Ruby
module SimpleForm
|
|
module Components
|
|
module Placeholders
|
|
def placeholder
|
|
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 has_placeholder?
|
|
nil
|
|
end
|
|
|
|
alias :disabled_placeholder :placeholder
|
|
|
|
def placeholder_text
|
|
@placeholder_text ||= options[:placeholder] || translate(:placeholders)
|
|
end
|
|
end
|
|
end
|
|
end |