From: Jason S. <jsw...@ya...> - 2003-05-14 11:07:51
|
Hi José_Accino, > I'm using original Phrame framework to make a medium size app. All > by all, it runs nice. I've a question, however. Is ActionForm->get > unable to return form data from multiple options fields?. Is your select named like and array? i.e. <select name="foo[]" multi="multi"> ... </select> then $ActionForm->Get(foo) should be an array. Here is a snippet from the upcoming article that deals with a similar, but not exact, issue: From a smarty template (trimmed down): {section name=g loop=$group} {assign var=gid value=$group[g].link_group_id} {if $smarty.section.g.first} <form action="{$action_link}" method="post"> <div> <table> {/if} <tr> <th colspan="2"> {if $smarty.section.g.first} <input type="hidden" name="{$action}" value="UpdGroup" /> {else} <hr /> {/if} <h2>{$group[g].group_name}</h2> </th> </tr> <tr> <th>Name:</th> <td> <!-- *********************** NOTICE THIS HIDDEN NAME *********************** --> <input type="hidden" name="groups[]" value="{$gid}" /> <input type="text" name="group_name{$gid}" value="{$group[g].group_name}" size="45" max="50" /> </td> </tr> <tr> <th>Description:</th> <td><textarea name="group_desc{$gid}" rows="4" cols="40">{$group[g].group_desc}</textarea></td> </tr> {if $smarty.section.g.last} <tr> <th colspan="2"> <hr /> <input type="submit" value="Update" /> </th> </tr> </table> </div> </form> {/if} {sectionelse} <h2>Warning</h2> <p>There are no groups, please add one.</p> {/section} And here is the extended ActionForm that processes it: <?php /** * GroupForm class definition * * @author Jason E. Sweat * @since 2003-04-29 * @package PHP_Architect_MVC_links_example * @subpackage Forms */ /** * GroupForm class definition * @package PHP_Architect_MVC_links_example * @subpackage Forms */ class GroupForm extends ActionForm { /** * update list */ var $_moUpdList; /** * override PutAll method for custom processing * * @param array $paIn input array * @return void */ function PutAll($paIn) { Parent::PutAll($paIn); $a_list = array(); // notice that I expect groups to be an array here $a_loop = $this->Get('groups'); if (is_array($a_loop)) { for ($i=&new ArrayIterator($a_loop); $i->IsValid(); $i->Next()) { $i_upd_key = (int)$i->GetCurrent(); $a_add = array( 'link_group_id' => $i_upd_key ,'group_name' => stripslashes($this->Get('group_name'.$i_upd_key)) ,'group_desc' => stripslashes($this->Get('group_desc'.$i_upd_key)) ); $a_list[] = $a_add; } } $this->_moUpdList =&new ArrayList($a_list); } /** * return list iterator for updates * * @return object list iterator */ function &GetList() { return $this->_moUpdList->ListIterator(); } } ?> > PS. Nice article on php|a, Jason. I look forward for the next one! Thank you. HTH Jason __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |