Re: HTML_QuickForm & Flexy & multiple arrays -> solution found
| From: | robert | Date: | Thu, 29 Jul 2004 15:32:56 +0000 |
| Subject: | Re: HTML_QuickForm & Flexy & multiple arrays -> solution found | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13910@lists.php.net to get a copy of this message | ||
Thanks for the hint.
I found the clue. It works if I put it like this :-)
{foreach:form.contact,key1,value1}
<tr>
<td class="element">key1: {key1:h} value1: {value1:h}</td>
<td class="element">{value1.firstName.label:h}</td>
<td class="element" align="right">{value1.lastName.html:h}</td>
</tr>
{foreach:value1.address,key2,value2}
<tr>
<td class="element">key2: {key2:h} value2: {value2:h}</td>
<td class="element">{value2.street.label:h}</td>
<td class="element" align="right">{value2.street.html:h}</td>
</tr>
{end:}
{end:}
cron@odi.com.br wrote:
Download the QuickForm package there are examples of how to use QF with FLexy. Angelo ----- Original Message ----- From: "robert" <robert@hollyroot.org> To: <pear-general@lists.php.net> Sent: Thursday, July 29, 2004 9:29 AM Subject: [PEAR] HTML_QuickForm & Flexy & multiple arraysHi 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> <tdclass="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 -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php