I am struggling to get a working custom implementation of a cck_phone field, documentation and an example of usage would be really appreciated. I have included my partially working code below. What seems to be not working is that the function cck_phone_phone_number_process expects to be able to retrieve information about the widget with

$instance = field_widget_instance($element, $form_state);
$settings = $instance['settings'];

However in my implementation, field_widget_instance($element, $form_state) returns NULL, resulting in both $instance and $settings being NULL and problems further on in the cck_phone_phone_number_process function.

My code to create the custom cck_phone field:

    $form_section['phone']['field_phone_home'] = array(
        '#type' => 'phone_number',
        '#field_parents' => array(
            'profile_personal_information'
        ),
        '#field_name' => 'field_phone_home',
        '#language' => 'und',
        '#delta' => 0,
    );

Comments

DrCord’s picture

Priority: Normal » Major
mwadi’s picture

This is how you set a phone value:

  $phone = array(
    'number' => $form_state['values']['number'],
    'country_codes' => $form_state['values']['country_codes'],
    'extension' => '');
  $wrapper->field_phone_number->set($phone);