Quick Multi Select Form
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.
Page Info | |
---|---|
Page Name : | XOOPSCubeLegacy/CookBook/QuickSelectForm |
Page aliases : | None |
Page owner : | Anonymous |
Can Read | |
Groups : | All visitors |
Users : | All visitors |
Can Edit | |
Groups : | Support Site Webmasters |
Users : | No one |
Counter: 15045,
today: 2,
yesterday: 0
Princeps date: 2007-04-23 (Mon) 20:39:30
Last-modified: 2007-04-23 (Mon) 20:39:30 (JST) (5065d) by Anonymous