Re: [PHPLIB] Need oohforms pointers From: Patrick _ (phplib <email protected>)
Date: 11/12/99

Ok, after changing it to $submit and adding a closing "}" I got something
that actually does something :) But, if I enter e.g. ctrl-a in the
commentbox then validation fails and the page with my values is presented
again together with the error message (I had pressed the checkbox). Only the
checkbox setting (was pressed) is thrown back at me unpressed. Any ideas why
(code attached below, phplib v7.2)?

Regards,
-Patrick

<?
$f = new form; // create a form object

// set up form elements
// $f->add_element(...);
// $f->add_element(...);
// $f->add_element(...);

$f->add_element(array("type"=>"text",
                "name"=>"foo",
                "valid_regex"=>"^[a-z]*$",
                "valid_e"=>"Letters only",
                "icase"=>1,
                "value"=>"default_value"));
$f->add_element(array("type"=>"checkbox",
                "name"=>"compress",
                "multiple"=>1));
$f->add_element(array("type"=>"textarea",
                "name"=>"comment",
                "rows"=>6,
                "cols"=>40,
                "value"=>""));
$o = array(array("label"=>"Please Select","value"=>0),
                array("label"=>"Apple","value"=>1),
                array("label"=>"Orange","value"=>2),
                array("label"=>"Pear","value"=>3),
                array("label"=>"Grape","value"=>4));
$f->add_element(array("type"=>"select",
                "name"=>"menu",
                "options"=>$o,
                "size"=>1,
                "valid_e"=>"Please select a fruit",
                "value"=>"apple"));
//
$f->add_element(array("type"=>"submit",
                "name"=>"submit",
                "value"=>"submit"));

if ($submit) // Is there data to process?
        if ($err = $f->validate()) { // Is the data valid?
                echo $err; // No Display error
                $f->load_defaults(); } // Load form with submitted data
        else { echo"DB handler here";
                }

$f->start("",POST,$sess->self_url(),"_self"); // Start displaying form

$f->show_element("foo");
echo "<br>";
$f->show_element("compress");
echo " Compress me";
echo "<br>";
$f->show_element("comment");
echo "<br>";
$f->show_element("menu");
echo "<br>";
$f->show_element("submit");
echo "<br>";

$f->finish(); // Finish form
?>

>From: Massimiliano Masserelli <negro <email protected>>
>To: phplib <email protected>
>Subject: Re: [PHPLIB] Need oohforms pointers
>Date: Fri, 12 Nov 1999 16:13:42 +0100
>
>On Fri, Nov 12, 1999 at 02:53:36PM +0000, Patrick _ wrote:
>
> P> if ($submitname)
>
>Try with
>
> if ($submit)
>
>Bye.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
-
PHP3 Base Library Mailing List. Send messages to <phplib <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-request <email protected>> in
the body, not the subject, of your message.