Class: RailsAdmin::Config::Fields::Types::String
- Inherits:
-
StringLike
- Object
- Base
- StringLike
- RailsAdmin::Config::Fields::Types::String
- Defined in:
- lib/rails_admin/config/fields/types/string.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Base::NAMED_INSTANCE_VARIABLES
Instance Attribute Summary
Attributes inherited from Base
#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section
Instance Method Summary collapse
Methods inherited from StringLike
Methods inherited from Base
#association?, #eager_load_values, #editable?, #errors, #filter_options, #form_default_value, #form_value, #generic_field_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #parse_input, #parse_value, #sort_column, #type, #type_css_class, #value, #virtual?
Methods included from Inspectable
Methods included from Groupable
Methods included from Hideable
#hidden?, #hide, included, #show
Methods included from Configurable
#has_option?, #register_deprecated_instance_option, #register_instance_option
Methods included from Proxyable
Constructor Details
This class inherits a constructor from RailsAdmin::Config::Fields::Base
Instance Method Details
#generic_help ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_admin/config/fields/types/string.rb', line 24 def generic_help text = "#{required? ? I18n.translate('admin.form.required') : I18n.translate('admin.form.optional')}. " if valid_length.present? && valid_length[:is].present? text += "#{I18n.translate('admin.form.char_length_of').capitalize} #{valid_length[:is]}." else max_length = [length, valid_length[:maximum] || nil].compact.min min_length = [0, valid_length[:minimum] || nil].compact.max if max_length text += if min_length == 0 "#{I18n.translate('admin.form.char_length_up_to').capitalize} #{max_length}." else "#{I18n.translate('admin.form.char_length_of').capitalize} #{min_length}-#{max_length}." end end end text end |
#input_size ⇒ Object
12 13 14 |
# File 'lib/rails_admin/config/fields/types/string.rb', line 12 def input_size [50, length.to_i].reject(&:zero?).min end |