From ba82eabcbc6b1224fe2bfc273d0c9194a29cc98a Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 9 Jul 2009 16:07:19 +0000 Subject: [PATCH] Fixed a bug created with each form table when that element was modified to ignore fields set to null. The original intention was that null simply meant 'no special configuration'. However, we needed a way to programatically enable/disable fields, so null was an obvious choice to use. Now that I'm about to check in, I think I should have just made a minor change to use false to skip a field, which would have been backwards compatible (except for the one place using null to exclude the field). However, it's done now, so what the heck. git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@290 97e9348a-65ac-dc4b-aefc-98561f571b83 --- views/contacts/edit.ctp | 28 ++++++++++++++-------------- views/customers/edit.ctp | 14 +++++++------- views/elements/form_table.ctp | 6 ++++++ views/leases/invoice.ctp | 2 +- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/views/contacts/edit.ctp b/views/contacts/edit.ctp index 5574fd9..163af2f 100644 --- a/views/contacts/edit.ctp +++ b/views/contacts/edit.ctp @@ -120,9 +120,9 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { elseif ($stype === 'new') { $fields = array ('type' => array('opts' => array('options' => $obj->varstore['phoneTypes'])), - 'phone' => null, + 'phone' => true, 'ext' => array('name' => "Extension"), - 'comment' => null, + 'comment' => true, ); } elseif ($stype === 'show') { @@ -149,12 +149,12 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { } elseif ($stype === 'new') { $fields = array - ('address' => null, - 'city' => null, - 'state' => null, + ('address' => true, + 'city' => true, + 'state' => true, 'postcode' => array('name' => 'Zip Code'), - 'country' => null, - 'comment' => null, + 'country' => true, + 'comment' => true, ); } elseif ($stype === 'show') { @@ -182,8 +182,8 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { } elseif ($stype === 'new') { $fields = array - ('email' => null, - 'comment' => null, + ('email' => true, + 'comment' => true, ); } elseif ($stype === 'show') { @@ -345,17 +345,17 @@ echo($this->element array('class' => 'item contact detail', 'caption' => isset($this->data['Contact']) ? 'Edit Contact' : 'New Contact', 'fields' => array - ('first_name' => null, - 'last_name' => null, - 'middle_name' => null, - 'display_name' => null, + ('first_name' => true, + 'last_name' => true, + 'middle_name' => true, + 'display_name' => true, 'company_name' => array('name' => 'Company'), 'id_federal' => array('name' => 'SSN'), 'id_local' => array('name' => 'ID #'), 'id_local_state' => array('name' => 'ID State'), /* 'id_local_exp' => array('name' => 'ID Expiration', */ /* 'opts' => array('empty' => true)), */ - 'comment' => null, + 'comment' => true, ))) . "\n"); echo $form->submit('Update') . "\n"; diff --git a/views/customers/edit.ctp b/views/customers/edit.ctp index b9c4ec9..9b66f61 100644 --- a/views/customers/edit.ctp +++ b/views/customers/edit.ctp @@ -120,17 +120,17 @@ function customerContactTypeDiv($obj, $stype, $values = null) { } elseif ($stype === 'new') { $fields = array - ('first_name' => null, - 'last_name' => null, - 'middle_name' => null, - 'display_name' => null, + ('first_name' => true, + 'last_name' => true, + 'middle_name' => true, + 'display_name' => true, 'company_name' => array('name' => 'Company'), 'id_federal' => array('name' => 'SSN'), 'id_local' => array('name' => 'ID #'), 'id_local_state' => array('name' => 'ID State'), /* 'id_local_exp' => array('name' => 'ID Expiration', */ /* 'opts' => array('empty' => true)), */ - 'comment' => null, + 'comment' => true, ); } elseif ($stype === 'show') { @@ -247,8 +247,8 @@ echo($this->element array('class' => 'item customer detail', 'caption' => isset($this->data['Customer']) ? 'Edit Customer' : 'New Customer', 'fields' => array - ('name' => null, - 'comment' => null, + ('name' => true, + 'comment' => true, ))) . "\n"); echo $form->submit('Update') . "\n"; diff --git a/views/elements/form_table.ctp b/views/elements/form_table.ctp index 6fc374e..cecc4ad 100644 --- a/views/elements/form_table.ctp +++ b/views/elements/form_table.ctp @@ -48,6 +48,12 @@ foreach ($fields AS $field => $config) { if (!isset($config)) continue; + if (is_bool($config) && !$config) + continue; + + if (is_bool($config) && $config) + $config = array(); + if (!isset($config['name'])) $config['name'] = implode(' ', array_map('ucfirst', explode('_', $field))); if (!isset($config['opts'])) diff --git a/views/leases/invoice.ctp b/views/leases/invoice.ctp index 76359f4..802db38 100644 --- a/views/leases/invoice.ctp +++ b/views/leases/invoice.ctp @@ -185,7 +185,7 @@ function addChargeSource(flash) { array('type' => 'text'), 'between' => 'EOM', ), - "amount" => null, + "amount" => true, "comment" => array('opts' => array('size' => 50)), ), ))) . "+\n";