contao / core-bundle

[READ-ONLY] Contao Core Bundle
GNU Lesser General Public License v3.0
123 stars 58 forks source link

Form field configuration issues #1622

Closed Toflar closed 6 years ago

Toflar commented 6 years ago

When you use a text form field and you set the validation to numeric characters (digit), you'll get an <input type="number"> field. For those fields the maxlength attribute is ignored (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#attr-maxlength) so it makes no sense to configure this. Instead, for this validation, max and min and even pattern would make sense.

m-vo commented 6 years ago

I think in most cases it even does not make sense that it's output as type="number" because of the default rendering of this type with up/down arrows in the common browsers.

fritzmg commented 6 years ago

I think in most cases it even does not make sense that it's output as type="number" because of the default rendering of this type with up/down arrows in the common browsers.

That's not really a reason not to use type="number"? ;) You should always use the most specific semantics for your form fields. Just makes things easier for everyone (in theory).

m-vo commented 6 years ago

Sure. The problem is the semantics: something can be a number but incrementing it does not necessarily make sense. I'd rather allow the type and pattern to be specified in the backend instead of hiding it under validation.

fritzmg commented 6 years ago

Sure. The problem is the semantics: something can be a number but incrementing it does not necessarily make sense.

That does not really matter as there is nothing else in the HTML5 specifications that would be suitable (yet). The front end should definitely use type="number". Not only does it provide a suitable HTML5 validation, but it also provides mobile users with a better user experience, since most mobile browsers will show the user a number keyboard by default for such types of inputs. The stepper on desktop browsers is just a nuisance.

leofeyer commented 6 years ago

Closed in favor of https://github.com/contao/contao/pull/25.