Index: sites/all/modules/cck_phone/cck_phone.install --- sites/all/modules/cck_phone/cck_phone.install (revision 61ccc9f) +++ sites/all/modules/cck_phone/cck_phone.install (revision 671d5208b8c8e9475b5c7a7db01a3eb1f0930ceb) @@ -27,6 +27,11 @@ 'length' => 6, 'not null' => FALSE, ), + 'comment' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + ), ), ); } Index: sites/all/modules/cck_phone/cck_phone.module --- sites/all/modules/cck_phone/cck_phone.module (revision 61ccc9f) +++ sites/all/modules/cck_phone/cck_phone.module (revision 671d5208b8c8e9475b5c7a7db01a3eb1f0930ceb) @@ -36,6 +36,9 @@ 'phone_number_extension' => array( 'render element' => 'element', ), + 'phone_number_comment' => array( + 'render element' => 'element', + ), 'cck_phone_formatter_global_phone_number' => array( 'variables' => array('element' => NULL), ), @@ -62,6 +65,7 @@ 'country_code_position' => 'after', 'enable_country_level_validation' => TRUE, 'enable_extension' => FALSE, + 'enable_comment' => FALSE, ), 'default_widget' => 'phone_number', 'default_formatter' => 'global_phone_number', @@ -167,6 +171,13 @@ '#description' => t('Check this to enable phone number extension field.'), ); + $form['enable_comment'] = array( + '#type' => 'checkbox', + '#title' => t('Enable phone comment support'), + '#default_value' => $settings['enable_comment'], + '#description' => t('Check this to enable phone number comment field.'), + ); + // Display country specific settings foreach (_cck_phone_custom_cc() as $cc) { $function = $cc . '_phone_field_settings'; @@ -260,6 +271,13 @@ } /** + * Theme function for phone comment. + */ +function theme_phone_number_comment($element = '') { + return t('
Comment: %comment', array('%comment' => $element['element'])); +} + +/** * Theme function for 'default' or global phone number field formatter. */ function theme_cck_phone_formatter_global_phone_number($element) { @@ -286,7 +304,12 @@ if (!empty($element['extension'])) { $phone = $phone . theme('phone_number_extension', $element['extension']); } + + // Comment + if (!empty($element['comment'])) { + $phone .= theme('phone_number_comment', $element['comment']); - } + } + } return $phone; } @@ -313,9 +336,9 @@ $phone = $element['number']; } - // Extension - if (!empty($element['extension'])) { - $phone = $phone . theme('phone_number_extension', $element['extension']); + // Comment + if (!empty($element['comment'])) { + $phone .= theme('phone_number_comment', $element['comment']); } } @@ -632,6 +655,17 @@ '#required' => FALSE, '#default_value' => isset($item['extension']) ? $item['extension'] : NULL, '#weight' => 2, + ); + } + if ($settings['enable_comment']) { + $element['comment'] = array( + '#type' => 'textfield', + '#maxlength' => 255, + '#size' => 15, + '#title' => t('Comment'), + '#required' => FALSE, + '#default_value' => isset($item['comment']) ? $item['comment'] : NULL, + '#weight' => 3, ); }