Re: How to $_POST from a grid
| From: | Bruno B B Magalhães | Date: | Wed, 24 Nov 2004 21:19:43 +0000 |
| Subject: | Re: How to $_POST from a grid | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-202799@lists.php.net to get a copy of this message | ||
Hy David,
well here is my code... I use smarty templating system for parsing values, but should give you a very clear idea of what must to be done.
========================== MODULES LISTING TEMPLATE ==========================
{include file="$controllerTemplates/head.tpl"}
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" id="administration_listing">
<tr>
<td class="administration_listing_head">{#head_name#}</td>
<td class="administration_listing_head">{#head_path#}</td>
<td class="administration_listing_head" align="center">{#head_level#}</td>
<td class="administration_listing_head" align="center">{#head_order#}</td>
<td class="administration_listing_head" align="center">{#head_visibility#}</td>
<td class="administration_listing_head" align="center">{#head_type#}</td>
<td class="administration_listing_head" align="center">{#head_status#}</td>
<td class="administration_listing_head" align="center" width="75">{#head_actions#}</td>
</tr>
{section name=m loop=$modules}
<tr>
<form action="{#Address#}{$controllerPath}/{$modulePath}/updatemodule" method="post">
<input type="hidden" name="moduleId" value="{$modules[m].moduleId}">
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" nowrap>{$modules[m].moduleName}</td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" nowrap><a href="{$serverPath}{$modules[m].moduleController}/{$modules[m].modulePath}" target="_blank">{$serverPath}{$modules[m].moduleController}/{$modules[m].modulePath}</a></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap><select name="moduleLevel" size="1" onchange="this.form.submit()">{html_options options=$levelrange selected=$modules[m].moduleLevel}</select></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap><select name="moduleOrder" size="1" onchange="this.form.submit()">{html_options options=$orderrange selected=$modules[m].moduleOrder}</select></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap><select name="moduleVisibility" size="1" onchange="this.form.submit()"><option value="0" {if $modules[m].moduleVisibility eq 0}selected{/if}>{$smarty.config.visibility_invisible}</option><option value="1" {if $modules[m].moduleVisibility eq 1}selected{/if}>{$smarty.config.visibility_visible}</option></select></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap><select name="moduleType" size="1" onchange="this.form.submit()"><option value="none" {if $modules[m].moduleType eq 'none'}selected{/if}>{$smarty.config.type_none}</option><option value="alias" {if $modules[m].moduleType eq 'alias'}selected{/if}>{$smarty.config.type_alias}</option><option value="default" {if $modules[m].moduleType eq 'default'}selected{/if}>{$smarty.config.type_default}</option></select></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap><select name="moduleStatus" size="1" onchange="this.form.submit()"><option value="0" {if $modules[m].moduleStatus eq 0}selected{/if}>{$smarty.config.status_inactive}</option><option value="1" {if $modules[m].moduleStatus eq 1}selected{/if}>{$smarty.config.status_active}</option></select></td>
<td class="administration_listing_row_{if $smarty.section.m.iteration is odd}one{else}two{/if}" align="center" nowrap width="75"><a href="{#Address#}{$controllerPath}/{$modulePath}/editmodule/{$modules[m].moduleId}"><img src="{#MediaAddress#}{#bEdit#}" alt="{#aEdit#}" border="0"></a><img src="{#MediaAddress#}{#tPixel#}" border="0" height="10" width="10">{if $smarty.session.userlevel >= 9}<a href="{#Address#}{$controllerPath}/{$modulePath}/deletemodule/{$modules[m].moduleId}"><img src="{#MediaAddress#}{#bDelete#}" alt="{#aDelete#}" border="0"></a>{/if}</td>
</form>
</tr>
{sectionelse}
<tr><td class="administration_listing_row_one" colspan="8" align="center" nowrap>{#message_no_modules#}</td></tr>
{/section}
</table>
{include file="$controllerTemplates/foot.tpl"}
==============================================================================
If you are not using smarty, just think the {section} tag as foreach($modules as $module) { .... } our also a faster one for($i=0; $i < $t; $i++) { .... } where $t = count($modules)-1;.
Best Regards,
Bruno B B Magalhães