Quickform with Smarty. Undefined index Error ??

From: Date: Tue, 29 Apr 2008 21:37:22 +0000
Subject: Quickform with Smarty. Undefined index Error ??
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28846@lists.php.net to get a copy of this message
Hello all, I am not only new to PHP/PEAR/Smarty but also to this list. Please forgive any newbie mistakes I make :) Thank you! I have setup QuickForm to be used with Smarty templates. The form displays fine but below the form I get numerous Undefined index Errors. ERRNO: 8 > TEXT: Undefined index: form > LOCATION: > /var/www/html/mysite/templates_c/%%ED^EDF^EDF8BD08%%example.tpl.php, line > 51, at April 29, 2008, 10:59 am Please note I am also using Smarty function Plugins. So, the template is called first and in return it loads the function.php file Am I calling the form correctly? (ofcourse its my code, so please help) I would really like to learn how to use QF. *Php Code: *(this is only the php code for the form, I could also include the entire function.php file if it helps)* * require_once PEAR_DIR . 'HTML/QuickForm.php'; $form =& new HTML_QuickForm('exampleForm'); // delivery options $form->addElement('radio', 'shipping', 'select a delivery method:', 'Best way shipping', 'bestway'); $form->addElement('radio', 'shipping', NULL, 'Will Call', 'willcall'); $form->addElement('radio', 'shipping', NULL, 'Delivery option', 'delivery'); $form->addElement('text', 'Number', 'number: ', array('size'=>20, 'maxlength'=>17)); $form->addElement('date','DATE','date: ', array('format'=> 'M Y', 'addEmptyOption' => 'true', 'emptyOptionValue' => '', 'emptyOptionText' => '', 'minYear'=> date('Y'),'maxYear'=> date('Y')+10)); $form->addElement('text', 'Name', 'Your name:'); // submit $form->addElement('submit', 'sended', 'continue'); // Filters: trim() function removes leading and trailing white spaces from data submitted $form->applyFilter('__ALL__', 'trim'); // validation rules: $form->addRule('shipping', 'Please select a shipping method.', 'required'); $form->addRule('Number', 'Please Enter Your Number.', 'required'); $form->addRule('Number', 'Please enter your correct number.', 'numeric'); $form->addRule('Number', 'Please enter your correct number.', 'minlength',15); $form->addRule('date', 'Please enter your date.', 'required'); $form->addRule('Name', 'Please enter your name.', 'required'); $form->addRule('Name', 'Please enter your name.', 'minlength',3); $form->addRule('Name', 'Please enter your name.', 'lettersonly'); // try to validate the form if ($form->validate()) { $form->freeze(); } else { require_once(SMARTY_DIR . 'Smarty.class.php'); require_once PEAR_DIR . 'HTML/QuickForm/Renderer/ArraySmarty.php'; $tpl =& new Smarty(); $tpl->template_dir = TEMPLATE_DIR; $tpl->compile_dir = COMPILE_DIR; $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); $renderer->setRequiredTemplate( '{strip} {if $error}<img src="../images/warning.png" alt="Warning: {$error|strip_tags|escape}" /> {/if} {$label} {/strip}' ); $renderer->setErrorTemplate('{$html}'); $form->accept($renderer); $tpl->assign('form', $renderer->toArray()); // render and display the template $tpl->display('example.tpl'); } *Template Code:* <form id="cc_shipping" method="post" action=""> <div class="boxContent"> <h3>Please enter your info:</h3> <table> <tr> <td width="140">{$form.Number.label}</td> <td>{$form.Number.html}</td> </tr> <tr> <td width="140">{$form.date.label}</td> <td>{$form.date.html}</td> </tr> <tr> <td width="140">{$form.Name.label}</td> <td>{$form.Name.html}</td> </tr> </table> </div> {$form.sended.html} {* display an overview of all form errors *} {foreach from=$form.errors item=error name=errorloop} {if $smarty.foreach.errorloop.first}<ul class="warning">{/if} <li>{$error}</li> {if $smarty.foreach.errorloop.last}</ul>{/if} {/foreach} </form> -- Sahand

« previous php.pear.general (#28846) next »