闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
6.2 KiB

  1. # Use this setup block to configure all options available in SimpleForm.
  2. SimpleForm.setup do |config|
  3. # Wrappers are used by the form builder to generate a
  4. # complete input. You can remove any component from the
  5. # wrapper, change the order or even add your own to the
  6. # stack. The options given below are used to wrap the
  7. # whole input.
  8. config.wrappers :default, class: :input,
  9. hint_class: :field_with_hint, error_class: :field_with_errors do |b|
  10. ## Extensions enabled by default
  11. # Any of these extensions can be disabled for a
  12. # given input by passing: `f.input EXTENSION_NAME => false`.
  13. # You can make any of these extensions optional by
  14. # renaming `b.use` to `b.optional`.
  15. # Determines whether to use HTML5 (:email, :url, ...)
  16. # and required attributes
  17. b.use :html5
  18. # Calculates placeholders automatically from I18n
  19. # You can also pass a string as f.input placeholder: "Placeholder"
  20. b.use :placeholder
  21. ## Optional extensions
  22. # They are disabled unless you pass `f.input EXTENSION_NAME => true`
  23. # to the input. If so, they will retrieve the values from the model
  24. # if any exists. If you want to enable any of those
  25. # extensions by default, you can change `b.optional` to `b.use`.
  26. # Calculates maxlength from length validations for string inputs
  27. b.optional :maxlength
  28. # Calculates pattern from format validations for string inputs
  29. b.optional :pattern
  30. # Calculates min and max from length validations for numeric inputs
  31. b.optional :min_max
  32. # Calculates readonly automatically from readonly attributes
  33. b.optional :readonly
  34. ## Inputs
  35. b.use :label_input
  36. b.use :hint, wrap_with: { tag: :span, class: :hint }
  37. b.use :error, wrap_with: { tag: :span, class: :error }
  38. ## full_messages_for
  39. # If you want to display the full error message for the attribute, you can
  40. # use the component :full_error, like:
  41. #
  42. # b.use :full_error, wrap_with: { tag: :span, class: :error }
  43. end
  44. # The default wrapper to be used by the FormBuilder.
  45. config.default_wrapper = :default
  46. # Define the way to render check boxes / radio buttons with labels.
  47. # Defaults to :nested for bootstrap config.
  48. # inline: input + label
  49. # nested: label > input
  50. config.boolean_style = :nested
  51. # Default class for buttons
  52. config.button_class = 'btn'
  53. # Method used to tidy up errors. Specify any Rails Array method.
  54. # :first lists the first message for each field.
  55. # Use :to_sentence to list all errors for each field.
  56. # config.error_method = :first
  57. # Default tag used for error notification helper.
  58. config.error_notification_tag = :div
  59. # CSS class to add for error notification helper.
  60. config.error_notification_class = 'error_notification'
  61. # ID to add for error notification helper.
  62. # config.error_notification_id = nil
  63. # Series of attempts to detect a default label method for collection.
  64. # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
  65. # Series of attempts to detect a default value method for collection.
  66. # config.collection_value_methods = [ :id, :to_s ]
  67. # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
  68. # config.collection_wrapper_tag = nil
  69. # You can define the class to use on all collection wrappers. Defaulting to none.
  70. # config.collection_wrapper_class = nil
  71. # You can wrap each item in a collection of radio/check boxes with a tag,
  72. # defaulting to :span.
  73. # config.item_wrapper_tag = :span
  74. # You can define a class to use in all item wrappers. Defaulting to none.
  75. # config.item_wrapper_class = nil
  76. # How the label text should be generated altogether with the required text.
  77. # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
  78. # You can define the class to use on all labels. Default is nil.
  79. # config.label_class = nil
  80. # You can define the default class to be used on forms. Can be overriden
  81. # with `html: { :class }`. Defaulting to none.
  82. # config.default_form_class = nil
  83. # You can define which elements should obtain additional classes
  84. # config.generate_additional_classes_for = [:wrapper, :label, :input]
  85. # Whether attributes are required by default (or not). Default is true.
  86. # config.required_by_default = true
  87. # Tell browsers whether to use the native HTML5 validations (novalidate form option).
  88. # These validations are enabled in SimpleForm's internal config but disabled by default
  89. # in this configuration, which is recommended due to some quirks from different browsers.
  90. # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
  91. # change this configuration to true.
  92. config.browser_validations = false
  93. # Collection of methods to detect if a file type was given.
  94. # config.file_methods = [ :mounted_as, :file?, :public_filename ]
  95. # Custom mappings for input types. This should be a hash containing a regexp
  96. # to match as key, and the input type that will be used when the field name
  97. # matches the regexp as value.
  98. # config.input_mappings = { /count/ => :integer }
  99. # Custom wrappers for input types. This should be a hash containing an input
  100. # type as key and the wrapper that will be used for all inputs with specified type.
  101. # config.wrapper_mappings = { string: :prepend }
  102. # Namespaces where SimpleForm should look for custom input classes that
  103. # override default inputs.
  104. # config.custom_inputs_namespaces << "CustomInputs"
  105. # Default priority for time_zone inputs.
  106. # config.time_zone_priority = nil
  107. # Default priority for country inputs.
  108. # config.country_priority = nil
  109. # When false, do not use translations for labels.
  110. # config.translate_labels = true
  111. # Automatically discover new inputs in Rails' autoload path.
  112. # config.inputs_discovery = true
  113. # Cache SimpleForm inputs discovery
  114. # config.cache_discovery = !Rails.env.development?
  115. # Default class for inputs
  116. # config.input_class = nil
  117. # Define the default class of the input wrapper of the boolean input.
  118. config.boolean_label_class = 'checkbox'
  119. # Defines if the default input wrapper class should be included in radio
  120. # collection wrappers.
  121. # config.include_default_input_wrapper_class = true
  122. # Defines which i18n scope will be used in Simple Form.
  123. # config.i18n_scope = 'simple_form'
  124. end