Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
456 views
in Q2A Core by

In qa-theme-base.php the function form_number() is specified as below. Note that type is "text", not "number". Is this correct? there are few differences between type text and number.

public function form_number($field, $style)
{
$this->output('<input ' . @$field['tags'] . ' type="text" value="' . @$field['value'] . '" class="qa-form-' . $style . '-number"/>');
}
Q2A version: q2a 1.7.5 customized

1 Answer

+1 vote
by
selected by
 
Best answer

I'd say it is correct but it could be improved. The number type seems to be a valid option to handle that: numbers. As it is a relatively new addition (HTML 5) Q2A has not yet introduced them. Usually, Q2A is a couple of steps behind the latest fashions. Usually, because of backwards compatibility reasons.

I know you might be wondering why this could be backwards incompatible. Well, there is a slight situation in which it may. That is CSS selectors. If someone is using an input[type="text"] selector in a custom theme or plugin, then it will no longer match. The idea is not to force backward-incompatible changes into a patch version (bear in mind the versioning: major.minor.patch). They should be valid in minor changes. It didn't happen in 1.8.x so maybe it would be better for that to be introduced in 1.9.0.

Anyway, Scott might not have thought on that or maybe he is planning to introduce that in 1.9.0. In any case at least he DID mention there are plans to eventually add them: https://github.com/q2a/question2answer/issues/611

Conclusion: for the time being, just expect a text type to be output but make sure to support number in your selectors.

...