logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

simple_form.rb (7045B)


  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, :with_label], 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. config.wrappers :with_block_label, class: [:input, :with_block_label], hint_class: :field_with_hint, error_class: :field_with_errors do |b|
  50. b.use :html5
  51. b.use :label
  52. b.use :hint, wrap_with: { tag: :span, class: :hint }
  53. b.use :input
  54. b.use :error, wrap_with: { tag: :span, class: :error }
  55. end
  56. # The default wrapper to be used by the FormBuilder.
  57. config.default_wrapper = :default
  58. # Define the way to render check boxes / radio buttons with labels.
  59. # Defaults to :nested for bootstrap config.
  60. # inline: input + label
  61. # nested: label > input
  62. config.boolean_style = :nested
  63. # Default class for buttons
  64. config.button_class = 'btn'
  65. # Method used to tidy up errors. Specify any Rails Array method.
  66. # :first lists the first message for each field.
  67. # Use :to_sentence to list all errors for each field.
  68. # config.error_method = :first
  69. # Default tag used for error notification helper.
  70. config.error_notification_tag = :div
  71. # CSS class to add for error notification helper.
  72. config.error_notification_class = 'error_notification'
  73. # ID to add for error notification helper.
  74. # config.error_notification_id = nil
  75. # Series of attempts to detect a default label method for collection.
  76. # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
  77. # Series of attempts to detect a default value method for collection.
  78. # config.collection_value_methods = [ :id, :to_s ]
  79. # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
  80. # config.collection_wrapper_tag = nil
  81. # You can define the class to use on all collection wrappers. Defaulting to none.
  82. # config.collection_wrapper_class = nil
  83. # You can wrap each item in a collection of radio/check boxes with a tag,
  84. # defaulting to :span.
  85. # config.item_wrapper_tag = :span
  86. # You can define a class to use in all item wrappers. Defaulting to none.
  87. # config.item_wrapper_class = nil
  88. # How the label text should be generated altogether with the required text.
  89. # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
  90. # You can define the class to use on all labels. Default is nil.
  91. # config.label_class = nil
  92. # You can define the default class to be used on forms. Can be overriden
  93. # with `html: { :class }`. Defaulting to none.
  94. # config.default_form_class = nil
  95. # You can define which elements should obtain additional classes
  96. # config.generate_additional_classes_for = [:wrapper, :label, :input]
  97. # Whether attributes are required by default (or not). Default is true.
  98. # config.required_by_default = true
  99. # Tell browsers whether to use the native HTML5 validations (novalidate form option).
  100. # These validations are enabled in SimpleForm's internal config but disabled by default
  101. # in this configuration, which is recommended due to some quirks from different browsers.
  102. # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
  103. # change this configuration to true.
  104. config.browser_validations = false
  105. # Collection of methods to detect if a file type was given.
  106. # config.file_methods = [ :mounted_as, :file?, :public_filename ]
  107. # Custom mappings for input types. This should be a hash containing a regexp
  108. # to match as key, and the input type that will be used when the field name
  109. # matches the regexp as value.
  110. # config.input_mappings = { /count/ => :integer }
  111. # Custom wrappers for input types. This should be a hash containing an input
  112. # type as key and the wrapper that will be used for all inputs with specified type.
  113. # config.wrapper_mappings = { string: :prepend }
  114. # Namespaces where SimpleForm should look for custom input classes that
  115. # override default inputs.
  116. # config.custom_inputs_namespaces << "CustomInputs"
  117. # Default priority for time_zone inputs.
  118. # config.time_zone_priority = nil
  119. # Default priority for country inputs.
  120. # config.country_priority = nil
  121. # When false, do not use translations for labels.
  122. # config.translate_labels = true
  123. # Automatically discover new inputs in Rails' autoload path.
  124. # config.inputs_discovery = true
  125. # Cache SimpleForm inputs discovery
  126. # config.cache_discovery = !Rails.env.development?
  127. # Default class for inputs
  128. # config.input_class = nil
  129. # Define the default class of the input wrapper of the boolean input.
  130. config.boolean_label_class = 'checkbox'
  131. # Defines if the default input wrapper class should be included in radio
  132. # collection wrappers.
  133. # config.include_default_input_wrapper_class = true
  134. # Defines which i18n scope will be used in Simple Form.
  135. # config.i18n_scope = 'simple_form'
  136. end