This topic is locked

Problem deleting records from list page - v3.1

10/5/2006 6:56:18 AM
PHPRunner General questions
J
jcottrell author

If a non-consecutive sub-set of the records on a list page have checkboxes to allow deletion, there is a bug that can cause either the wrong record to be deleted or an "Undefined offset" error message.
Looking at *_list.htm, I think the problem is here:
{if $allow_delete}

<td align="center">

{if $row.1editable}

<input type=checkbox name="mdelete[]" value="{$row.1recno}">

<input type=hidden name="mdelete1[]" value="{$row.1id1}">

{/if}

&nbsp;</td>

{/if}
Should be
{if $allow_delete}

<td align="center">

<input type=hidden name="mdelete1[]" value="{$row.1id1}">

{if $row.1editable}

<input type=checkbox name="mdelete[]" value="{$row.1recno}">

{/if}

&nbsp;</td>

{/if}

Alexey admin 10/5/2006

Hi,
thank you for pointing me to this bug.

We'll fix it in the next PHPRunner update this week.
You are absolutely correct. The modification you suggested fixes the error.

Pfeiffer 10/6/2006

Can you please publish the correct syntax of the code-snippet in list.htm,

so we can correct it before an "accident" happens ?
--- wrong snippet ---

if @TABLE.bDelete##

if GroupSecurity## {if $allow_delete} ##endif##

<td align="center">

if SecurityEditOwn## {if $row.##@i##editable} ##endif##

<input type=checkbox name="mdelete[]" value="{$row.##@i##recno}">

foreach @TABLE.arrKeyFields as @k##

<input type=hidden name="mdelete##@index##[]" value="{$row.##@i##id##@index##}">

endfor##

if SecurityEditOwn## {/if} ##endif##

&nbsp;</td>

if GroupSecurity## {/if} ##endif##

endif##


Best regards

Uwe Pfeiffer

Alexey admin 10/6/2006

Uwe,
here is the fixed snippet:

##if @TABLE.bDelete##

if GroupSecurity## {if $allow_delete} ##endif##

<td align="center">

if SecurityEditOwn## {if $row.##@i##editable} ##endif##

<input type=checkbox name="mdelete[]" value="{$row.##@i##recno}">

if SecurityEditOwn## {/if} ##endif##

foreach @TABLE.arrKeyFields as @k##

<input type=hidden name="mdelete##@index##[]" value="{$row.##@i##id##@index##}">

endfor##

&nbsp;</td>

if GroupSecurity## {/if} ##endif##

endif


The same applies to templates\list_vertical.htm file.