Modified the form table to support a variety of extra texts and/or columns
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@232 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -8,6 +8,40 @@
|
||||
* @package pmgr
|
||||
*/
|
||||
|
||||
$include_before = false;
|
||||
if (isset($before) && $before)
|
||||
$include_before = true;
|
||||
foreach ($fields AS $field => $config) {
|
||||
if (isset($config['before']))
|
||||
$include_before = true;
|
||||
}
|
||||
|
||||
$include_between = false;
|
||||
if (isset($between) && $between)
|
||||
$include_between = true;
|
||||
foreach ($fields AS $field => $config) {
|
||||
if (isset($config['between']))
|
||||
$include_between = true;
|
||||
}
|
||||
|
||||
$include_after = false;
|
||||
if (isset($after) && $after)
|
||||
$include_after = true;
|
||||
foreach ($fields AS $field => $config) {
|
||||
if (isset($config['after']))
|
||||
$include_after = true;
|
||||
}
|
||||
|
||||
|
||||
$column_class = array();
|
||||
if ($include_before)
|
||||
$column_class[] = 'before';
|
||||
$column_class[] = 'field';
|
||||
if ($include_between)
|
||||
$column_class[] = 'between';
|
||||
$column_class[] = 'value';
|
||||
if ($include_after)
|
||||
$column_class[] = 'after';
|
||||
|
||||
$rows = array();
|
||||
foreach ($fields AS $field => $config) {
|
||||
@@ -22,12 +56,63 @@ foreach ($fields AS $field => $config) {
|
||||
$field = $field_prefix . '.' . $field;
|
||||
|
||||
$config['opts']['label'] = false;
|
||||
$rows[] = array($config['name'],
|
||||
$form->input($field, $config['opts']));
|
||||
$config['opts']['div'] = false;
|
||||
|
||||
$cells = array();
|
||||
if ($include_before) {
|
||||
if (isset($config['before']))
|
||||
$cells[] = $config['before'];
|
||||
elseif (isset($before) && $before)
|
||||
$cells[] = $before;
|
||||
else
|
||||
$cells[] = null;
|
||||
}
|
||||
|
||||
$name = $config['name'];
|
||||
if (isset($config['with_name_before']))
|
||||
$name = $config['with_name_before'] . $name;
|
||||
elseif (isset($with_name_before))
|
||||
$name = $with_name_before . $name;
|
||||
if (isset($config['with_name_after']))
|
||||
$name = $name . $config['with_name_after'];
|
||||
elseif (isset($with_name_after))
|
||||
$name = $name . $with_name_after;
|
||||
$cells[] = $name;
|
||||
|
||||
if ($include_between) {
|
||||
if (isset($config['between']))
|
||||
$cells[] = $config['between'];
|
||||
elseif (isset($between) && $between)
|
||||
$cells[] = $between;
|
||||
else
|
||||
$cells[] = null;
|
||||
}
|
||||
|
||||
$value = $form->input($field, $config['opts']);
|
||||
if (isset($config['with_value_before']))
|
||||
$value = $config['with_value_before'] . $value;
|
||||
elseif (isset($with_value_before))
|
||||
$value = $with_value_before . $value;
|
||||
if (isset($config['with_value_after']))
|
||||
$value = $value . $config['with_value_after'];
|
||||
elseif (isset($with_value_after))
|
||||
$value = $valeu . $with_value_after;
|
||||
$cells[] = $value;
|
||||
|
||||
if ($include_after) {
|
||||
if (isset($config['after']))
|
||||
$cells[] = $config['after'];
|
||||
elseif (isset($after) && $after)
|
||||
$cells[] = $after;
|
||||
else
|
||||
$cells[] = null;
|
||||
}
|
||||
|
||||
$rows[] = $cells;
|
||||
}
|
||||
|
||||
echo $this->element('table',
|
||||
compact('class', 'caption', 'headers',
|
||||
'rows', 'row_class', 'suppress_alternate_rows') +
|
||||
array('column_class' => array('field', 'value'),
|
||||
));
|
||||
'rows', 'row_class', 'suppress_alternate_rows',
|
||||
'column_class')
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user