HTML_Quickform_controller and Smarty

From: Date: Sat, 24 Sep 2005 20:59:52 +0000
Subject: HTML_Quickform_controller and Smarty
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21098@lists.php.net to get a copy of this message
Hello, I am using HTML_Quickform_controller to create a wizard with 5 pages. On one page I need to pass an array to display repeating elements on the next. I have not been able to get Smarty to resolve a recursive element name. I have looked up recursion threads on Smarty and checked out QF examples but haven't figured out how to fix things. Any help will be greatly appreciated! Thanks. Here is the code snippet from this page. Context - The page is supposed to pull a list of performance measures and IDs from the db and allow the user to enter a baseline number and target against each measure that can then be saved. The number of performance measures is dynamic and depends on user selections on prior page(s). +++ Bottomline - I want this HTML <table> </tr> <td>J1</td> <td>Jobs retained</td> <td><input type="text" name="measureBaseline1"></td> <td><input type="text" name="measureTarget1></td> </tr> <tr> <td>J1</td> <td>Jobs retained</td> <td><input type="text" name="measureBaseline2"></td> <td><input type="text" name="measureTarget2></td> </tr> </table> +++++ //Here is the Smarty template. Something is screwed up in the way the variables are being resolved. I get Array.measureTitle0.label etc. in the output! I have tried several combinations of backticks and double quotes but no luck. {* form5.tpl *} <table> <tr> <th>Measure Name</th> <th>Type</th> <th>Baseline</th> <th>Target</th> </tr> {section name=i loop=$form_data.count.label} {* form_data is assigned in HTML_QuickForm_Action_Display *} <tr> <td>{"$form_data.measureName$smarty.section.i.index.label"}</td> <td>{"$form_data.measureTitle$smarty.section.i.index.label"}</td> <td>{"$form_data.measureBaseline$smarty.section.i.index.html"}</td> <td>{"$form_data.measureTarget$smarty.section.i.index.html"}</td> </tr> {/section} </table> //Here is the code behind the page class Page_Step5 extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; $this->template = 'form5.tpl'; $getMeasures = "Select measure_id, measure_title from measures; $measures =& $db->getAssoc($getMeasures); $count=0; foreach ($measures as $measureID => $measureTitle) { ++$count; $IDs[$count] = "measureID" . $count; $measureTitles[$count] = "measureTitle" . $count; $baselines[$count] = "measureBaseline" . $count; $targets[$count] = "measureTarget" . $count; $this->addElement('static', $measureTitles[$count], $measure_title); $this->addElement('text', $baselines[$count], 'Baseline:'); $this->addElement('text', $targets[$count], 'Target:'); } $prevnext[] =& $this->createElement('submit', $this->getButtonName('back'), '< Back'); $prevnext[] =& $this->createElement('submit', $this->getButtonName('next'), 'Next >'); $this->addGroup($prevnext, 'buttons', '', '&nbsp;', false); $this->setDefaultAction('next'); }

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