Forum OpenACS Development: Re: Invalid input syntax for integer

Collapse
Posted by Iuri Sampaio on
A good solution can be achieved by simply changing ad_form's element to element_1:integer(text).
That way, validation comes within the acs-template pkg.

This option would even reduce the amount of code within ad_form -on_submit, or ad_page_contract blocks.

Nevertheless, I wonder what would be necessary if I'd chosen JavaScript instead, separated from acs-template,

Best wishes,
Iuri

Collapse
Posted by Gustaf Neumann on
The proper way for HTML5 is to use an "input" field with type "number" and an integer "step", maybe a "min"/"max" value [1]. The HTML5 input types with their attributes are supported by the xowiki form fields, which are not integrated (yet) with ad_forms.

For the ad_page_contract, you do not necessarily have to have a validate block, but you should use in the "argspec" the type "integer "(or "naturalnum", etc.) [2]. The validate block is just needed for detailed checks (check for certain integers, checks against the db, etc.)

[1] https://www.wufoo.com/html5/types/7-number.html
[2] https://openacs.org/api-doc/proc-view?proc=ad_page_contract&source_p=1

Collapse
Posted by Iuri Sampaio on
Thanks! Nice reference, btw. I didn't know Wufoo.com