module SimpleForm::Components::Maxlength
Needs to be enabled in order to do automatic lookups.
Public Instance Methods
maxlength(wrapper_options = nil)
click to toggle source
# File lib/simple_form/components/maxlength.rb, line 6 def maxlength(wrapper_options = nil) input_html_options[:maxlength] ||= maximum_length_from_validation || limit nil end
Private Instance Methods
find_length_validator()
click to toggle source
# File lib/simple_form/components/maxlength.rb, line 23 def find_length_validator find_validator(:length) end
has_tokenizer?(length_validator)
click to toggle source
# File lib/simple_form/components/maxlength.rb, line 27 def has_tokenizer?(length_validator) length_validator.options[:tokenizer] end
maximum_length_from_validation()
click to toggle source
# File lib/simple_form/components/maxlength.rb, line 13 def maximum_length_from_validation maxlength = options[:maxlength] if maxlength.is_a?(String) || maxlength.is_a?(Integer) maxlength else length_validator = find_length_validator maximum_length_value_from(length_validator) end end
maximum_length_value_from(length_validator)
click to toggle source
# File lib/simple_form/components/maxlength.rb, line 31 def maximum_length_value_from(length_validator) if length_validator length_validator.options[:is] || length_validator.options[:maximum] end end