cvs: pear /HTML_QuickForm/docs QuickForm_example2.php

From: Date: Fri, 14 Jun 2002 19:15:50 +0000
Subject: cvs: pear /HTML_QuickForm/docs QuickForm_example2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4621@lists.php.net to get a copy of this message
jrust Fri Jun 14 15:15:50 2002 EDT Modified files: /pear/HTML_QuickForm/docs QuickForm_example2.php Log: Added examples of advanced checkbox, multiple select (without using getElement()), and cleaned up a few bad tags . Index: pear/HTML_QuickForm/docs/QuickForm_example2.php diff -u pear/HTML_QuickForm/docs/QuickForm_example2.php:1.2 pear/HTML_QuickForm/docs/QuickForm_example2.php:1.3 --- pear/HTML_QuickForm/docs/QuickForm_example2.php:1.2 Thu Apr 18 10:20:02 2002 +++ pear/HTML_QuickForm/docs/QuickForm_example2.php Fri Jun 14 15:15:50 2002 @@ -1,4 +1,6 @@ +<?php /** $Id: QuickForm_example2.php,v 1.3 2002/06/14 19:15:50 jrust Exp $ */ ?> <html> + <title>QuickForm Example 2</title> <body> <?php /** @@ -15,26 +17,35 @@ // clear all templates so we can give it a custom look $form->clearAllTemplates(); +// select list array +$selectListArray = array( + 'Windows' => 'windows', + 'Linux' => 'linux', + 'Irix' => 'irix', + 'Mac' => 'mac', +); + // Fills with some defaults values $defaultValues['tmp_textarea'] = ' Test Text Area With line breaks'; -$defaultValues['tmp_radio'] = 'Y'; -$defaultValues['tmp_text2[0]'] = '123'; -$defaultValues['tmp_text2[1]'] = '456'; -$defaultValues['tmp_text2[2]'] = '789'; +$defaultValues['tmp_text2'][0] = '123'; +$defaultValues['tmp_text2'][1] = '456'; +$defaultValues['tmp_text2'][2] = '789'; +$defaultValues['tmp_checkbox'] = 'checked'; +$defaultValues['tmp_select'] = 'linux'; +$defaultValues['tmp_multipleSelect'][0] = array('linux', 'mac'); // Fill with some constant values. // Constant is not overridden by POST, GET, or defaultValues // when values are being filled in -$constantValues['tmp_hidden'] = 25; -$constantValues['tmp_text'] = 'constant text'; +$constantValues['tmp_radio'] = 'Y'; +$constantValues['tmp_text']['ab'] = 'constant text'; $form->setDefaults($defaultValues); $form->setConstants($constantValues); - -$form->addElement('hidden','tmp_hidden'); +$form->addElement('hidden','tmp_hidden', 'value'); $form->addData(' <table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee"> <tr> @@ -57,7 +68,8 @@ </td> </tr> <td align="left">'); -$form->addElement('text','tmp_text',null,'size="30"'); +$form->addElement('text','tmp_text[ab]',null,'size="10"'); +$form->addElement('text','tmp_text[bc]',null,'size="10"'); $form->addData(' </td> <td align="right"> @@ -69,26 +81,54 @@ </td> </tr> <tr> - <td align="center" bgcolor="#cccccc" colspan="2"> - Group of Text Boxes + <td align="left" bgcolor="#cccccc"> + Array of Text Boxes + </td> + <td align="right" bgcolor="#cccccc"> + Advanced Check Box </td> </tr> <tr> - <td colspan="2" align="center"'); + <td align="left">'); // a group of text boxes in an array $form->addElement('text','tmp_text2[0]',null,'size="3"'); $form->addElement('text','tmp_text2[1]',null,'size="3"'); $form->addElement('text','tmp_text2[2]',null,'size="3"'); $form->addData(' </td> + <td align="right">'); +// advanced checkbox will always return a value, even when not checked +$form->addElement('advcheckbox','tmp_checkbox',null,'Please Check',null,array('not checked', 'checked')); +$form->addData(' + </td> </tr> <tr> - <td colspan="2" align="center"'); + <td align="left" bgcolor="#cccccc"> + Select List + </td> + <td align="right" bgcolor="#cccccc"> + Multiple Select List + </td> + </tr> + <tr> + <td align="left" valign="top">'); +$form->addElement('select', 'tmp_select', null, $selectListArray); +$form->addData(' + </td> + <td align="right">'); +$form->addElement('select', 'tmp_multipleSelect[0]', null, $selectListArray, array('multiple' => 'multiple', 'size' => 4)); +$form->addData(' + </td> + </tr> + <tr> + <td colspan="2" align="center">'); +$form->addElement('reset','tmp_submit','Reset Form'); $form->addElement('submit','tmp_submit','Submit Form'); $form->addData(' </td> </tr> </table>'); +$form->addRule('tmp_text','Must enter text value','required',null,'client'); $form->display(); echo "\n<HR> <b>Submitted Values: </b><br />\n"; @@ -97,4 +137,3 @@ ?> </body> </html> -

« previous php.pear.cvs (#4621) next »