XOOPSCubeLegacy​/CookBook

Quick Multi Select Form anchor.png

XoopsSimpleObject class is helpful, so you may use it in many cases. In addition, Legacy has some smarty plugins to embed values of objects in template for XoopsSimpleObject. xoops_optionsArray is one of them and is useful for multi select form.

When you push options which are array of XoopsSimpleObject to a render target, you may write a template as the following;

<select name="name_id[]">
 <{foreach item=object from$objects}>
   <{if $object->get('id') == $actionForm->get('name_id')}>
     <option value="<{$object->getShow('id')}>" selected><{$object->getShow('name')}></option>
   <{else}>
     <option value="<{$object->getShow('id')}>"><{$object->getShow('name')}></option>
   <{/if}>
 <{/foreach}>
</select>

By using xoops_optionsArray, you can write the same template as the folowwing;

<select name="name_id[]">
 <{xoops_optionsArray from=$objects value=id label=name default=$actionForm->get('name_id')}>
</select>

The case where this plugin is the most useful is multi select form. You don't need to change template code little.

<select name="name_id[]" mutiple>
 <{xoops_optionsArray from=$objects value=id label=name default=$actionForm->get('name_id')}>
</select>

The plugin changes its process, if 'default' is array.


Front page   Freeze Diff Backup Copy Rename ReloadPrint View   New Page Page list Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom) Powered by xpWiki
Counter: 14393, today: 1, yesterday: 2
Princeps date: 2007-04-23 (Mon) 20:39:30
Last-modified: 2007-04-23 (Mon) 20:39:30 (JST) (4416d) by Anonymous

Welcome | News | Overview | Documentation | Forum | Tutorialstop
Brasilian | French | German | Greek | Japanese | Korean | Russian | T-Chinese
Powered by XOOPS Cube 2001-2011 The XOOPS Cube Project