diff --git a/includes/phone.element.inc b/includes/phone.element.inc index 14bdaa9..487a4d5 100644 --- a/includes/phone.element.inc +++ b/includes/phone.element.inc @@ -67,8 +67,28 @@ function phone_element_process($element, &$form_state, $form) { $settings = $element['#phone_settings']; + if (empty($element['comment'])) { + $element['comment'] = array(); + } + + if (empty($element['number'])) { + $element['number'] = array(); + } + + if (empty($element['countrycode'])) { + $element['countrycode'] = array(); + } + + if (empty($element['country_code_markup'])) { + $element['country_code_markup'] = array(); + } + + if (empty($element['extension'])) { + $element['extension'] = array(); + } + if ($settings['enable_comment'] && !empty($settings['comment_allowed_values'])) { - $element['comment'] = array( + $element['comment'] = $element['comment'] + array( '#type' => 'select', '#options' => $settings['comment_allowed_values'], '#weight' => $settings['comment_allowed_values_position'] == 'after' ? 5 : -5, @@ -77,13 +97,13 @@ function phone_element_process($element, &$form_state, $form) { ); } else { - $element['comment'] = array( + $element['comment'] = $element['comment'] + array( '#type' => 'hidden', '#value' => isset($item['comment']) ? $item['comment'] : NULL, ); } - $element['number'] = array( + $element['number'] = $element['number'] + array( '#type' => !empty($settings['use_tel_input']) ? 'phone_tel' : 'textfield', '#maxlength' => $settings['number_size'], '#size' => $settings['number_size'], @@ -98,12 +118,12 @@ function phone_element_process($element, &$form_state, $form) { if (!$country_options['all_country_codes'] && count($country_selection) == 1) { $countrycode = reset($country_selection); $country = phone_countries($countrycode); - $element['countrycode'] = array( + $element['countrycode'] = $element['countrycode'] + array( '#type' => 'hidden', '#value' => $countrycode, ); if (!$country_options['country_codes']['hide_single_cc']) { - $element['country_code_markup'] = array( + $element['country_code_markup'] = $element['country_code_markup'] + array( '#type' => 'item', '#markup' => $value = $country, '#weight' => ($country_options['country_code_position'] == 'after' ? 1 : -1), @@ -111,7 +131,7 @@ function phone_element_process($element, &$form_state, $form) { } } else { - $element['countrycode'] = array( + $element['countrycode'] = $element['countrycode'] + array( '#type' => 'select', '#options' => phone_countries($country_options['all_country_codes'] ? NULL : $country_selection), '#weight' => ($country_options['country_code_position'] == 'after' ? 1 : -1), @@ -126,7 +146,7 @@ function phone_element_process($element, &$form_state, $form) { } if ($settings['enable_extension']) { - $element['extension'] = array( + $element['extension'] = $element['extension'] + array( '#type' => 'textfield', '#maxlength' => $settings['extension_size'], '#size' => $settings['extension_size'], @@ -137,7 +157,7 @@ function phone_element_process($element, &$form_state, $form) { ); } else { - $element['extension'] = array( + $element['extension'] = $element['extension'] + array( '#type' => 'hidden', '#value' => isset($item['extension']) ? $item['extension'] : NULL, );