Displaying Quickform validation errors with ITStatic renderer

From: Date: Mon, 29 Jan 2007 15:50:33 +0000
Subject: Displaying Quickform validation errors with ITStatic renderer
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26433@lists.php.net to get a copy of this message
Hi I am trying to get a validation error message appear at the top of my form but they always appear in a separate window. I am using the examples from the Pear site. I must be doing something very silly! Any pointers would be very welcome. Thank you John <?php require_once ("HTML/QuickForm.php"); $form = new HTML_QuickForm('myform', 'POST'); $form->addElement('header', 'myheader', 'Registration form'); $form->addElement('hidden', 'session', '123456'); $name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', array('size' => 10)); $name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', array('size' => 10)); $form->addGroup($name, 'name', 'Name:', '-'); $form->addElement('text', 'email', 'Your email:'); $select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy'); $form->addElement('select', 'country', 'Country:', $select); $form->addElement('reset', 'reset', 'Reset'); $form->addElement('submit', 'submit', 'Register'); $form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter."); $form->addRule('email','Enter email','required','null','client'); require_once 'HTML/Template/Sigma.php'; require_once 'HTML/QuickForm/Renderer/ITStatic.php'; $tpl =& new HTML_Template_Sigma('.'); $tpl->loadTemplateFile('test.htm'); // or whatever you called it $renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl); $renderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>'); $renderer->setErrorTemplate('<font color="red">{error}</font><br />{html}'); $form->validate(); $form->accept($renderer); $tpl->show(); ?> AND <html> <head><title>My Form</title> {myform_javascript} </head> <body> <form {myform_attributes}> {myform_session_html} <!-- BEGIN myform_error_loop --> <font color="red">{myform_error}</font><br /> <!-- END myform_error_loop --> <table> <tr><th colspan="2">{myform_myheader}</th></tr> <tr><td>{myform_name_first_html}</td><td>{myform_name_last_html}</td></tr> <tr><td>{myform_name_first_label}</td><td>{myform_name_last_label}</td></tr> <tr><td>{myform_email_label}</td><td>{myform_email_html}</td></tr> <tr><td>{myform_country_label}</td><td>{myform_country_html}</td></tr> <tr><td colspan="2" align="right">{myform_reset_html} {myform_submit_html}</td></tr> </table> <br /><br /> {myform_news_html} </form> </body> </html>

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