Terminator is not public.
This commit is contained in:
parent
2d7cc56382
commit
725ca0f4a1
12
README.rdoc
12
README.rdoc
|
@ -170,14 +170,14 @@ Instead of using the text and mark options from required, you can also overwrite
|
|||
You have a set of options available to configure SimpleForm:
|
||||
|
||||
* component_tag => default tag used in components. by default is :span.
|
||||
|
||||
* components => stack of components used in form builder to create the input.
|
||||
You can add or remove any of this components as you need.
|
||||
* terminator => the last component will call this terminator. By default it's
|
||||
a lambda returning an empty string.
|
||||
* collection_label_methods => all methods available to detect the label for a
|
||||
collection.
|
||||
* collection_value_methods => all methods available to detect the value for a
|
||||
collection.
|
||||
|
||||
* collection_label_methods => all methods available to detect the label for a collection.
|
||||
|
||||
* collection_value_methods => all methods available to detect the value for a collection.
|
||||
|
||||
* wrapper_tag => wrapper tag to wrap the inputs. By default no wrapper exists.
|
||||
|
||||
To do it so you just need to create a file inside your initializer folder and use the configurations as follows:
|
||||
|
|
|
@ -20,13 +20,9 @@ module SimpleForm
|
|||
SimpleForm::Components::Error
|
||||
]
|
||||
|
||||
# The terminator sent to the last component
|
||||
mattr_accessor :terminator
|
||||
@@terminator = lambda { "" }
|
||||
|
||||
# Series of attemps to detect a default label method for collection
|
||||
mattr_accessor :collection_label_methods
|
||||
@@collection_label_methods = [ :name, :title, :to_s ]
|
||||
@@collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
||||
|
||||
# Series of attemps to detect a default value method for collection
|
||||
mattr_accessor :collection_value_methods
|
||||
|
|
|
@ -2,6 +2,8 @@ module SimpleForm
|
|||
class FormBuilder < ActionView::Helpers::FormBuilder
|
||||
attr_reader :template, :object_name, :object, :attribute, :column, :input_type, :options
|
||||
|
||||
TERMINATOR = lambda { "" }
|
||||
|
||||
# Basic input helper, combines all components in the stack to generate input
|
||||
# html based on options the user define and some guesses through
|
||||
# database column information. By default a call to input will generate
|
||||
|
@ -64,7 +66,7 @@ module SimpleForm
|
|||
def input(attribute, options={})
|
||||
define_simple_form_attributes(attribute, options)
|
||||
|
||||
component = SimpleForm.terminator
|
||||
component = TERMINATOR
|
||||
SimpleForm.components.reverse.each do |klass|
|
||||
next if @options[klass.basename] == false
|
||||
component = klass.new(self, component)
|
||||
|
@ -131,7 +133,7 @@ module SimpleForm
|
|||
#
|
||||
def error(attribute, options={})
|
||||
define_simple_form_attributes(attribute, :error_html => options)
|
||||
SimpleForm::Components::Error.new(self, SimpleForm.terminator).call
|
||||
SimpleForm::Components::Error.new(self, TERMINATOR).call
|
||||
end
|
||||
|
||||
# Creates a hint tag for the given attribute. Accepts a symbol indicating
|
||||
|
@ -147,7 +149,7 @@ module SimpleForm
|
|||
def hint(attribute, options={})
|
||||
attribute, options[:hint] = nil, attribute if attribute.is_a?(String)
|
||||
define_simple_form_attributes(attribute, :hint => options.delete(:hint), :hint_html => options)
|
||||
SimpleForm::Components::Hint.new(self, SimpleForm.terminator).call
|
||||
SimpleForm::Components::Hint.new(self, TERMINATOR).call
|
||||
end
|
||||
|
||||
# Creates a default label tag for the given attribute. You can give a label
|
||||
|
@ -168,7 +170,7 @@ module SimpleForm
|
|||
options = args.extract_options!
|
||||
define_simple_form_attributes(attribute, :label => options.delete(:label),
|
||||
:label_html => options, :required => options.delete(:required))
|
||||
SimpleForm::Components::Label.new(self, SimpleForm.terminator).call
|
||||
SimpleForm::Components::Label.new(self, TERMINATOR).call
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,7 +8,7 @@ class ErrorTest < ActionView::TestCase
|
|||
f.input_type = type
|
||||
f.options = options
|
||||
|
||||
error = SimpleForm::Components::Error.new(f, SimpleForm.terminator)
|
||||
error = SimpleForm::Components::Error.new(f, SimpleForm::FormBuilder::TERMINATOR)
|
||||
concat(error.call)
|
||||
yield error if block_given?
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ class ErrorTest < ActionView::TestCase
|
|||
f.input_type = type
|
||||
f.options = options
|
||||
|
||||
hint = SimpleForm::Components::Hint.new(f, SimpleForm.terminator)
|
||||
hint = SimpleForm::Components::Hint.new(f, SimpleForm::FormBuilder::TERMINATOR)
|
||||
concat(hint.call)
|
||||
yield hint if block_given?
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ class InputTest < ActionView::TestCase
|
|||
f.input_type = type
|
||||
f.options = options
|
||||
|
||||
input = SimpleForm::Components::Input.new(f, SimpleForm.terminator)
|
||||
input = SimpleForm::Components::Input.new(f, SimpleForm::FormBuilder::TERMINATOR)
|
||||
concat(input.call)
|
||||
yield input if block_given?
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class LabelTest < ActionView::TestCase
|
|||
f.input_type = type
|
||||
f.options = options
|
||||
|
||||
label = SimpleForm::Components::Label.new(f, SimpleForm.terminator)
|
||||
label = SimpleForm::Components::Label.new(f, SimpleForm::FormBuilder::TERMINATOR)
|
||||
concat(label.call)
|
||||
yield label if block_given?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue