A website template with lots of features, built with ruby on rails.

simple_form.rb 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 => :lookup`
  23. # to the input. If so, they will retrieve the values from the model
  24. # if any exists. If you want to enable the lookup for 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. end
  39. # The default wrapper to be used by the FormBuilder.
  40. config.default_wrapper = :default
  41. # Define the way to render check boxes / radio buttons with labels.
  42. # Defaults to :nested for bootstrap config.
  43. # inline: input + label
  44. # nested: label > input
  45. config.boolean_style = :nested
  46. # Default class for buttons
  47. config.button_class = 'btn'
  48. # Method used to tidy up errors. Specify any Rails Array method.
  49. # :first lists the first message for each field.
  50. # Use :to_sentence to list all errors for each field.
  51. # config.error_method = :first
  52. # Default tag used for error notification helper.
  53. config.error_notification_tag = :div
  54. # CSS class to add for error notification helper.
  55. config.error_notification_class = 'alert alert-error'
  56. # ID to add for error notification helper.
  57. # config.error_notification_id = nil
  58. # Series of attempts to detect a default label method for collection.
  59. # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
  60. # Series of attempts to detect a default value method for collection.
  61. # config.collection_value_methods = [ :id, :to_s ]
  62. # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
  63. # config.collection_wrapper_tag = nil
  64. # You can define the class to use on all collection wrappers. Defaulting to none.
  65. # config.collection_wrapper_class = nil
  66. # You can wrap each item in a collection of radio/check boxes with a tag,
  67. # defaulting to :span. Please note that when using :boolean_style = :nested,
  68. # SimpleForm will force this option to be a label.
  69. # config.item_wrapper_tag = :span
  70. # You can define a class to use in all item wrappers. Defaulting to none.
  71. # config.item_wrapper_class = nil
  72. # How the label text should be generated altogether with the required text.
  73. # config.label_text = lambda { |label, required| "#{required} #{label}" }
  74. # You can define the class to use on all labels. Default is nil.
  75. config.label_class = 'control-label'
  76. # You can define the class to use on all forms. Default is simple_form.
  77. # config.form_class = :simple_form
  78. # You can define which elements should obtain additional classes
  79. # config.generate_additional_classes_for = [:wrapper, :label, :input]
  80. # Whether attributes are required by default (or not). Default is true.
  81. # config.required_by_default = true
  82. # Tell browsers whether to use the native HTML5 validations (novalidate form option).
  83. # These validations are enabled in SimpleForm's internal config but disabled by default
  84. # in this configuration, which is recommended due to some quirks from different browsers.
  85. # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
  86. # change this configuration to true.
  87. config.browser_validations = false
  88. # Collection of methods to detect if a file type was given.
  89. # config.file_methods = [ :mounted_as, :file?, :public_filename ]
  90. # Custom mappings for input types. This should be a hash containing a regexp
  91. # to match as key, and the input type that will be used when the field name
  92. # matches the regexp as value.
  93. # config.input_mappings = { /count/ => :integer }
  94. # Custom wrappers for input types. This should be a hash containing an input
  95. # type as key and the wrapper that will be used for all inputs with specified type.
  96. # config.wrapper_mappings = { string: :prepend }
  97. # Default priority for time_zone inputs.
  98. # config.time_zone_priority = nil
  99. # Default priority for country inputs.
  100. # config.country_priority = nil
  101. # When false, do not use translations for labels.
  102. # config.translate_labels = true
  103. # Automatically discover new inputs in Rails' autoload path.
  104. # config.inputs_discovery = true
  105. # Cache SimpleForm inputs discovery
  106. # config.cache_discovery = !Rails.env.development?
  107. # Default class for inputs
  108. # config.input_class = nil
  109. end