闭社主体 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.

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