while ($a = $r->next()) {
// desc will be the title of the column
$a['desc'] = $a['Field'];
- $a['display'] = true;
+ // display_list decides whether to display the field in 'list' mode
+ $a['display_list'] = true;
+ // display_item decides whether a field is displayed in 'item edition' mode
+ $a['display_item'] = true;
if (substr($a['Type'],0,8) == 'varchar(') {
// limit editing box size
}
// change display of a field
- public function describe($name, $desc, $display)
+ public function describe($name, $desc, $display_list, $display_item=true)
{
$this->vars[$name]['desc'] = $desc;
- $this->vars[$name]['display'] = $display;
+ $this->vars[$name]['display_list'] = $display_list;
+ $this->vars[$name]['display_item'] = $display_item;
}
// add a join table, when deleting a row corresponding entries will be deleted in these tables
} elseif ($descr['Type'] == 'ip_address') {
$val = ip2long($val);
}
- } elseif ($descr['display']) {
+ } elseif ($descr['display_item']) {
$cancel = true;
$page->trigError("Il manque le champ ".$field);
}
$it = XDB::iterator("SELECT t.* {$optional_fields} FROM {$this->table} AS t {$optional_joints} WHERE " . $this->get_where_clause() . " $sort");
$this->nbfields = 0;
foreach ($this->vars as $field => $descr)
- if ($descr['display']) $this->nbfields++;
+ if ($descr['display_list']) $this->nbfields++;
$page->assign('list', $it);
}
$page->assign('t', $this);
</script>
<table class="bicol">
<tr>
- {foreach from=$t->vars item=myval key=myvar}{if $myval.display}
+ {foreach from=$t->vars item=myval key=myvar}{if $myval.display_list}
<th style="cursor:pointer" onclick="redirect('{$t->pl}/sort{if $t->sortfield eq $myvar && !$t->sortdesc}desc{/if}/{$myvar}')">{$myval.desc}{if $t->sortfield eq $myvar}{if $t->sortdesc}{icon name="bullet_arrow_down"}{else}{icon name="bullet_arrow_up"}{/if}{/if}</th>
{/if}{/foreach}
{if !$hideactions}
{/if}
{iterate from=$list item=myrow}
<tr class="{cycle values="pair,impair"}">
-{foreach from=$t->vars item=myval}{if $myval.display}
+{foreach from=$t->vars item=myval}{if $myval.display_list}
<td>
{assign var="myfield" value=$myval.Field}
{if $myfield eq $t->idfield}
{/if}
</th>
</tr>
- {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if (($myfield neq $t->idfield) or ($t->idfield_editable)) and $myval.display}
+ {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if (($myfield neq $t->idfield) or ($t->idfield_editable)) and $myval.display_item}
<tr class="{cycle values="pair,impair"}">
<td>
<strong>{$myval.desc}</strong>