MyBB Community Forums

Full Version: Expand class_DefaultForm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'd like to see a generate_numeric_field function.  Currently plugin developers have to use a text field which means additional validation may be required so something doesn't break.

function generate_numeric_field($name, $value, $options=array())
$optionsarray:
- min
- max
- step
- required
- id
- style
- class
Sorry for not responding sooner, but I think this is a good idea.
Sound good.
I noticed this is done on the feature branch, but what I'm wondering is why it still uses input type="text". Most browsers support type="number" and those that don't treat it as text. I think it would make more sense to use number.

https://github.com/mybb/mybb/blob/featur...m.php#L131
To be honest, I didn't know there was an input type="number" Wink

If it works with the major browsers, then it should be changed.
The number input type is part of the HTML5 specification. We decided (some may say wrongly...) to stick with XHTML so strictly speaking it wouldn't be a valid element.

http://www.w3.org/TR/html-markup/input.number.html
So the decision is between validity (which is not given for MyBB 1.8 anyway) and user experience? I'd vote for the users then and implement it as number please.
I'm all for user experience, I'm just pointing out that it isn't valid HTML. There are some people who obsess about making sure their site validates (though this is the ACP so idk why they'd care).
My feeling about XHTML is that if HTML5 is the future of web design, it makes no real sense to try to stick with old standards. Then again, it'd be a shame to break an otherwise perfectly compatible software with one little field. Toungue

I'm just excited a number field is being added. It will save some time attempting constant validation on stuff. (I assume validation will still be necessary to prevent users from doing weird stuff with the forms, but hey, at least the validation won't need to be user friendly. Toungue)
By the way, shouldn't value be an integer rather than a string?