varstore = compact('methodTypes', 'methodPreferences', 'contactPhones', 'phoneTypes', 'contactAddresses', 'contactEmails'); //pr($this->data); /********************************************************************** ********************************************************************** ********************************************************************** ********************************************************************** * Javascript */ function contactMethodDiv($obj, $type, $legend, $values = null) { $div = // BEGIN type-div '
' . "\n" . // BEGIN type-fieldset '
' . "\n" . ''.$legend.' #%{id} (%{remove})' . "\n" . // BEGIN source-div '
' . "\n" . // BEGIN source-fieldset '
' . "\n" . //'Source' . "\n" . '' ; if (!isset($values)) { foreach (array('Existing', 'New') AS $sname) { $stype = strtolower($sname); $div .= '' . "\n" . ' ' . "\n" . ' '; } } $div .= "\n"; if (isset($values)) { $div .= contactMethodTypeDiv($obj, $type, 'show', $values); } else { $div .= contactMethodTypeDiv($obj, $type, 'existing'); $div .= contactMethodTypeDiv($obj, $type, 'new'); } $div .= // END source-fieldset '
' . "\n" . // END source-div '
' . "\n" . // BEGIN method-div '
element ('form_table', array('class' => "item contact-{$type} entry", 'field_prefix' => 'Contact'.ucfirst($type).'.%{id}.ContactsMethod', 'fields' => array ( 'preference' => array ('opts' => array ('options' => $obj->varstore['methodPreferences'], 'selected' => (isset($values) ? $values['ContactsMethod']['preference'] : null), )), 'type' => array ('opts' => array ('options' => $obj->varstore['methodTypes'], 'selected' => (isset($values) ? $values['ContactsMethod']['type'] : null), )), 'comment' => array ('opts' => array ('value' => (isset($values) ? $values['ContactsMethod']['comment'] : null), )), ))) . "\n" . // END method-div '
' . "\n" . // END type-fieldset '
' . "\n" . // END type-div '
' ; return $div; } function contactMethodTypeDiv($obj, $type, $stype, $values = null) { $element = 'form_table'; if ($type === 'phone') { if ($stype === 'existing') { $fields = array ('id' => array('name' => 'Phone/Ext', 'opts' => array('options' => $obj->varstore['contactPhones'])), ); } elseif ($stype === 'new') { $fields = array ('type' => array('opts' => array('options' => $obj->varstore['phoneTypes'])), 'phone' => true, 'ext' => array('name' => "Extension"), 'comment' => true, ); } elseif ($stype === 'show') { $element = 'table'; $column_class = array('field', 'value'); $rows = array (array('Type', $values['type']), array('Phone', $values['phone']), array('Extension', $values['ext']), array('Comment', $values['comment']), ); } else { die("\n\nInvalid stype ($stype)\n\n"); } } elseif ($type === 'address') { if ($stype === 'existing') { $fields = array ('id' => array('name' => 'Address', 'opts' => array('options' => $obj->varstore['contactAddresses'])), ); } elseif ($stype === 'new') { $fields = array ('address' => true, 'city' => true, 'state' => true, 'postcode' => array('name' => 'Zip Code'), 'country' => true, 'comment' => true, ); } elseif ($stype === 'show') { $element = 'table'; $column_class = array('field', 'value'); $rows = array (array('Address', preg_replace("/\n/", "
", $values['address'])), array('City', $values['city']), array('State', $values['state']), array('Zip Code', $values['postcode']), array('Country', $values['country']), array('Comment', $values['comment']), ); } else { die("\n\nInvalid stype ($stype)\n\n"); } } elseif ($type === 'email') { if ($stype === 'existing') { $fields = array ('id' => array('name' => 'Email', 'opts' => array('options' => $obj->varstore['contactEmails'])), ); } elseif ($stype === 'new') { $fields = array ('email' => true, 'comment' => true, ); } elseif ($stype === 'show') { $element = 'table'; $column_class = array('field', 'value'); $rows = array (array('Email', $values['email']), array('Comment', $values['comment']), ); } } else { die("\n\nInvalid type ($type)\n\n"); } return // BEGIN sourcetype-div '' . "\n" . ''; } //pr($this->data); ?> ' . "\n"; echo $form->create('Contact', array('action' => 'edit')) . "\n"; echo $form->input('id') . "\n"; echo($this->element ('form_table', array('class' => 'item contact detail', 'caption' => isset($this->data['Contact']) ? 'Edit Contact' : 'New Contact', 'fields' => array ('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' => true, ))) . "\n"); echo $form->submit('Update') . "\n"; ?>
Phone Numbers
Add a Phone Number
Mailing Addresses
Add a Mailing Address
Email Addresses
Add an Email Address
submit('Update') . "\n"; echo $form->submit('Cancel', array('name' => 'cancel')) . "\n"; echo $form->end() . "\n"; echo '' . "\n";