Forum OpenACS Q&A: Floating point numbers in ad_form

Collapse
Posted by Keith Paskett on

I'm trying to use ad_form to generate a form with floating point numbers and I'm getting nowhere in the documentation.

ad_form documentation says "Because of this, you can use any form builder datatype or widget with this procedure", but can't find a list of form builder datatypes.

Here's my code snippet:

        {q1:integer(text)        {label " Planning - Hours"}
                                {optional}
                                {section " Program Management"}
                                {html {size 5}} }
 

I'v tried replacing integer with real, float, and number with no success.

Collapse
Posted by Rocael Hernández Rizzardini on
search for valid types in the api-doc, do a search for: "template::data::validate::"
like here: https://openacs.org/api-doc/proc-search?query_string=template%3A%3Adata%3A%3Avalidate%3A%3A&search_type=Search&name_weight=5&param_weight=3&doc_weight=2
use the oacs 4.6.2 and it has a float validation.
you'll use as (if ain't worng)

{q1:float  {label " Planning - Hours"}
                                {optional}
                                {section " Program Management"}
                                {html {size 5}} }

I just created a naturalnum also, I'll submit the patch later =)

Collapse
Posted by Keith Paskett on
4.6.2 appears to not have a float validation type.

I just set up a new ACS instance and float is not one of the types. Maybe it's in 4.7. I'll see about getting that and patch my 4.6.2 for now.

Collapse
Posted by Jeff Lu on
will this help? you can use this:

ad_page_contract_filter_proc_float

Ive read the source and from what ive seen it uses regular expressions to check the variable

Collapse
Posted by Keith Paskett on
That's a different beast but good to know it's there.

I checked out the head revision of OpenACS via CVS and float validation was there for the form manager.