simple form: enable HTML5 maxlength validations.

Makes it so that models that have maximum length validations will add
maxlength attributes to form fields. This includes flag reasons, appeal
reasons, and forum topic titles.

Partially fixes #4519 (Add "n/m characters remaining" character counter to the appeal reason).

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/maxlength
This commit is contained in:
evazion
2020-06-25 16:28:18 -05:00
parent 883856d4af
commit 5e23861bea

View File

@@ -39,7 +39,7 @@ SimpleForm.setup do |config|
# Calculates maxlength from length validations for string inputs
# and/or database column lengths
b.optional :maxlength
b.use :maxlength
# Calculate minlength from length validations for string inputs
b.optional :minlength
@@ -129,7 +129,7 @@ SimpleForm.setup do |config|
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
config.browser_validations = false
config.browser_validations = true
# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name