HTML_QuickForm & Flexy & multiple arrays
| From: | robert | Date: | Thu, 29 Jul 2004 12:29:10 +0000 |
| Subject: | HTML_QuickForm & Flexy & multiple arrays | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13905@lists.php.net to get a copy of this message | ||
Hi there,
I am using HTML_QuickForm to create forms with a variable number of
fields, depending on the number of contacts I have in a given company.
Example code:
-----------------8<-----------------------------------------------------------------
$form = new HTML_QuickForm ($formName ='formTest', $method = 'post');
$numberOfContacts = 5;
for($i = 0; $i < $numberOfContacts; $i++){
$form->addElement('text', "contact[$i][firstName]", 'Name' ,
array('size' => 20, 'maxlength' => 255));
$form->addElement('text', "contact[$i][lastName]", 'Name' ,
array('size' => 20, 'maxlength' => 255));
for($k = 0; $k < $numberOfAddresses; $k++){
$form->addElement('text', "contact[$i][address][$k][street]",
"contact[$i][address][$k][street]" , array('size' => 20, 'maxlength' =>
255));
} // for
} // for
$form->addElement('reset', 'reset', 'Reset');
$form->addElement('submit', 'submit', 'Submit');
-----------------8<-----------------------------------------------------------------
Now I want to use a templating system to create some nice forms. I am
trying out flexy (but maybe I have to a different one)
This does not work:
{foreach:form.contact,key1,value1}
<tr>
<td class="element">key1: {key1:h} value1: {value1:h}</td>
<td class="element">{form.contact.{key1}.firstName.label:h}</td>
<td class="element"
align="right">{form.contact.{key1}.lastName.html:h}</td>
</tr>
{foreach:form.contact.{key1}.address,key2,value2}
<tr>
<td class="element">key2: {key2:h} value2: {value2:h}</td>
<td
class="element">{form.contact.{key1}.address.{key2}.street.label:h}</td>
<td class="element"align="right">{form.contact.{key1}.address.{key2}.street.html:h}</td> </tr> {end:} {end:} QUESTIONS 1. how can access my array with flexy? 2. If it is not possible, can anybody of you recommend a templaing system where this will work? thnx in advance robert