RSS Comments for HTML Forms generation and validation

28 Jan 2003 21:07 mlemos Thumbs up

Re: Recovering values for select, multiple fields?

> I don't get the values out of the
> submission automatically. Am I missing a
> trick, or do I have to use the Changes
> property specifically to extract info
> from select/multiple fields? (or some
> other way)?
>

Use GetInputValue() function. For SELECT MULTIPLE fields it will return an array with all selected values.

24 Jan 2003 13:58 berendes

Recovering values for select, multiple fields?
When I define a select/multiple field in the test_smarty_form, like so:
$testform->AddInput(array(
"TYPE"=>"select",
"NAME"=>"MatchingFundType",
"ID"=>"MatchingFundType",
"SIZE"=>"9",
"MULTIPLE"=>"1",
"OPTIONS"=>array( "community"=>"community", "ecdev"=>"economic development", "empworkdev"=>"employment"),
"LABEL"=>"Check one or more categorical <u>s</u>ources of matching funds",
"ACCESSKEY"=>"s"
));
I don't get the values out of the submission automatically. Am I missing a trick, or do I have to use the Changes property specifically to extract info from select/multiple fields? (or some other way)?

20 Dec 2002 19:22 mlemos Thumbs up

Re: love it, need help with validateasset

> (1) looks like "validateasset"
> does not work with <input
> type=checkbox name=chesspiece
> value=knight> <input type=checkbox
> name=chesspiece value=queen>
> construct to ensure that at least one is
> checked. is that right?

No. Custom validation logic should be handled with custom validation functions.

> (2) not clear how
> "validateasset" should work
> for a type=select. both versions (smarty
> and not) of the test form show a
> validate for credit card type, but it
> looks like you can leave it set to
> unknown, and php won't complain.

If you do not want to accept unknown credit card type, change it to undefined and make it value be an empty string. Then use ValidateAsNotEmpty.

20 Dec 2002 15:35 berendes

love it, need help with validateasset
THis could work well for us - thanks

(1) looks like "validateasset" does not work with <input type=checkbox name=chesspiece value=knight> <input type=checkbox name=chesspiece value=queen> construct to ensure that at least one is checked. is that right?

(2) not clear how "validateasset" should work for a type=select. both versions (smarty and not) of the test form show a validate for credit card type, but it looks like you can leave it set to unknown, and php won't complain.

10 Nov 2002 20:44 mortent Thumbs up

How to make it work with register_globals=off
Hi there
Just to let you know out there...

Put this in the top of the page or somewhat near the
top.

foreach ($HTTP_POST_VARS as $k=>$v) {
$tmp = $k;
$$tmp = $v;
}

.. and change this..
$f->LoadInputValues($f->WasSubmitted($doit));
.. to this...
$f->LoadInputValues($f->WasSubmitted($tmp));

and change this ..
if ($f->WasSubmitted($doit))
.. to this...
if ($f->WasSubmitted($tmp))

And everything works...

I got it from Vinay Kumar who posted it at the website
for OOHForms

Bedst regards

21 Oct 2002 21:54 mortent Thumbs up

Re: AddInput. type=Select, OPTIONS and database connection

>
> If you were using Metabase, you could
> try this other class that has a function
> that does exactly what you want:
>
> www.phpclasses.org/dat...
For my dbconnections I use: ADOdb from
php.weblogs.com, because I started out with
RoleAuth from your site:
www.phpclasses.org/bro...

I used to write all my code (php), for some years (4
years) , Im not at programmer but a theacher. Then
again I like writing php.

Thanks for your help .. it really helped go get a littel
further.


>
>
> Anyway, try this:
>
> $sem = $db->Execute($sql =
> "SELECT * FROM
> ".$cfg->universityTable."")
> or die
>
("DatabaseError:".$db->ErrorMsg()."");
>
> $options=array();
>
> while(!$sem->EOF)
> {
>
$options[$cfg->universityId]=$cfg->universityAlias];
> $sem->MoveNext();
> }
>
> $f->AddInput(array(
> "TYPE"=>"select",
> "NAME"=>"seminarium",
> "VALUE"=>2,
> "SIZE"=>1,
> "OPTIONS"=$options
> ));
>


I ended up with this:

$sem = $db->Execute($sql = "SELECT * FROM
".$cfg->universityTable."") or die ("DatabaseError:
".$db->ErrorMsg()."");
$options = array();
while(!$sem->EOF) {

$options[]=$sem->fields[$cfg->universityId]=$sem->fields[$cfg->universityAlias];

$sem->MoveNext();
}


$f->AddInput(array(
"TYPE"=>"select",
"NAME"=>"seminarium",
"VALUE"=>0,
"SIZE"=>1,
"OPTIONS"=>$options
));

Thanks again...

21 Oct 2002 07:32 mlemos Thumbs up

Re: AddInput. type=Select, OPTIONS and database connection

> I been working with your form generation
> and validation
> for some days now. And I like it very
> much. But....
>
> How can I get this to work ... ?
>
> $sem = $db->Execute($sql =
> "SELECT * FROM
> ".$cfg->universityTable."")
> or die ("DatabaseError:
> ".$db->ErrorMsg()."");
>
>
> $f->AddInput(array(
>
> "TYPE"=>"select",
>
> "NAME"=>"seminarium",
> "VALUE"=>2,
> "SIZE"=>1,
> while(!$sem->EOF)
> {
>
> "OPTIONS"=>array($sem->fields[$cfg->universityId]
>
> =>
> '$sem->fields[$cfg->universityAlias]',
> )
> $sem->MoveNext();
> }
> ));
>
>
> I know its all wrong, but I dont know
> how to loop the
> "OPTIONS" ....

If you were using Metabase, you could try this other class that has a function that does exactly what you want:

www.phpclasses.org/dat...

Anyway, try this:

$sem = $db->Execute($sql = "SELECT * FROM ".$cfg->universityTable."")
or die ("DatabaseError:".$db->ErrorMsg()."");

$options=array();

while(!$sem->EOF)
{
$options[$cfg->universityId]=$cfg->universityAlias];
$sem->MoveNext();
}

$f->AddInput(array(
"TYPE"=>"select",
"NAME"=>"seminarium",
"VALUE"=>2,
"SIZE"=>1,
"OPTIONS"=$options
));

21 Oct 2002 02:58 mortent Thumbs up

AddInput. type=Select, OPTIONS and database connection
I been working with your form generation and validation
for some days now. And I like it very much. But....

How can I get this to work ... ?

$sem = $db->Execute($sql = "SELECT * FROM
".$cfg->universityTable."") or die ("DatabaseError:
".$db->ErrorMsg()."");

$f->AddInput(array(
"TYPE"=>"select",
"NAME"=>"seminarium", "VALUE"=>2, "SIZE"=>1,
while(!$sem->EOF)
{

"OPTIONS"=>array($sem->fields[$cfg->universityId]
=> '$sem->fields[$cfg->universityAlias]', )
$sem->MoveNext();
}
));


I know its all wrong, but I dont know how to loop the
"OPTIONS" ....

The documentation is fine (too technical.. for me) and
the exsamples are much better...

(sorry.. but don't know where else to ask..)

Morten Therkildsen

18 Sep 2001 17:38 mlemos Thumbs up

Re: Problem calling from class

> Unfortunately, when I place the code
> into a class, Output function does not
> recognize the local output function.
>
%
> Output(array("Function"=>"Output",
> "EndOfLine"=>"\n"))
>
> The 8/29/01 version reports:
> Fatal error: Call to undefined
> function: output() in forms.php on line
> 761
> (761 is the first line after the is
> statements in the Output function.)
>
> I'm not a php expert and I'm expect
> this is a simple error on my part.
> Thanks.

Your Output function needs to be always a global function, not a class function.

18 Sep 2001 17:16 davidccallaghan

Problem calling from class
I have a large OOP project with a single class that is used to generate the html form code.

Your form class is much better than my form class and I've been testing it from a single test page like your subscription sample.

Unfortunately, when I place the code into a class, Output function does not recognize the local output function.

Output(array("Function"=>"Output", "EndOfLine"=>"\n"))

The 8/29/01 version reports:
Fatal error: Call to undefined function: output() in forms.php on line 761
(761 is the first line after the is statements in the Output function.)

I'm not a php expert and I'm expect this is a simple error on my part. Thanks.

Screenshot

Project Spotlight

Notepas

A text editor aimed at developers.

Screenshot

Project Spotlight

FeResPost

A .NET assembly, COM component, and Ruby extension for finite element results post-processing.