Question on HTML_QuickForm: Validation ignored if specify form action

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

 

I just started to try HTML_QuickForm, and got a problem on setting form
action in the  HTML_QuickForm constructor.

 

 It looks like if I set the form action other than default, i.e., self,
all the validation rule is ignored, the page goes directly to the
process.php after click on submit.

 

Could you help me to figure it out? 

 

Many thanks.

 

Ying

 

____________________________________________________________

 

<?php

    require_once "HTML/QuickForm.php";

    require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';

    require_once 'Smarty.class.php';

 

    $form = new HTML_QuickForm('frmTest', 'post', 'process.php');

    $form->addElement('text', 'txtAge', 'Age?');

    $form->addElement('text', 'txtTelephone', 'Telephone number?');

    $form->addElement('reset', 'btnClear', 'Clear');

    $form->addElement('submit', 'btnSubmit', 'Submit');

 

    $form->addRule('txtAge', 'Age is required', 'required');

 

    $form->validate();

 

    // Create the template object

    $tpl =& new Smarty;

    $tpl->template_dir = '.';

    $tpl->compile_dir  = '/tmp';

 

    // Create the renderer object    

    $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);

    $renderer->setRequiredTemplate(

   '{if $error}

        <font color="red">{$label}</font>

    {else}

        {$label}

        {if $required}

            <font color="red" size="1">*</font>

        {/if}

    {/if}'

);

 

    // build the HTML for the form

    $form->accept($renderer);

 

    // assign array with form data

    $tpl->assign('form_data', $renderer->toArray());

 

    // parse and display the template

    $tpl->display('smarty2.tpl');

?>

 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux