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 ('label_attributes' => array('class' => 'required'), 'opts' => array ('options' => $obj->varstore['methodPreferences'], 'selected' => (isset($values) ? $values['ContactsMethod']['preference'] : null), ), 'after' => "Intended purpose for this method of communication.", ), 'type' => array ('label_attributes' => array('class' => 'required'), 'opts' => array ('options' => $obj->varstore['methodTypes'], 'selected' => (isset($values) ? $values['ContactsMethod']['type'] : null), ), 'after' => "How / Where this communication reaches the contact.", ), 'comment' => array ('label_attributes' => array('class' => 'optional empty'), 'opts' => array ('value' => (isset($values) ? $values['ContactsMethod']['comment'] : null), ), 'after' => "Optional: Comments on how this form of communication relates to the contact.", ), ))) . "\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('label_attributes' => array('class' => 'required empty'), 'name' => 'Phone/Ext', 'opts' => array('options' => $obj->varstore['contactPhones'])), ); } elseif ($stype === 'new') { $fields = array ('type' => array('label_attributes' => array('class' => 'required'), 'opts' => array('options' => $obj->varstore['phoneTypes']), 'after' => "Physical type of the phone."), 'phone' => array('label_attributes' => array('class' => 'required empty'), 'after' => "Required: Phone number."), 'ext' => array('name' => "Extension", 'label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Extension number."), 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Comments about this phone number."), ); } 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' => array('label_attributes' => array('class' => 'required empty'), 'after' => "Required: First line of mailing address."), 'city' => array('label_attributes' => array('class' => 'required empty'), 'after' => "Required."), 'state' => array('label_attributes' => array('class' => 'required empty'), 'after' => "Required."), 'postcode' => array('name' => 'Zip Code', 'label_attributes' => array('class' => 'required empty'), 'after' => "Required."), 'country' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: USA is presumed."), 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Comments about this mailing address."), ); } 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', 'label_attributes' => array('class' => 'required'), 'opts' => array('options' => $obj->varstore['contactEmails'])), ); } elseif ($stype === 'new') { $fields = array ('email' => array('label_attributes' => array('class' => 'required empty'), 'after' => "Required: E-mail address."), 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Comments about this email address."), ); } 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 ('last_name' => array('label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended."), 'first_name' => array('label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended."), 'middle_name' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional."), 'company_name' => array('name' => 'Company', 'label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Company name, if corporate contact."), 'display_name' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional with first/last name; Required otherwise."), 'id_federal' => array('name' => 'SSN', 'label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Social Security Number."), 'id_local' => array('name' => 'ID #', 'label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended: Driver's license, for example."), 'id_local_state' => array('name' => 'ID State', 'label_attributes' => array('class' => 'recommended empty'), 'after' => "Recommended: State which issued the ID."), /* 'id_local_exp' => array('name' => 'ID Expiration', */ /* 'opts' => array('empty' => true)), */ 'comment' => array('label_attributes' => array('class' => 'optional empty'), 'after' => "Optional: Comments about this contact."), ))) . "\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";