function _webform_submit_phone in Webform Phone Number 7
A hook for changing the input values before saving to the database. Webform expects a component to consist of a single field, or a single array of fields. If you have a component that requires a deeper form tree you must flatten the data into a single array using this callback or by setting #parents on each field to avoid data loss and/or unexpected behavior. Note that Webform will save the result of this function directly into the database.
Parameters
$component: A Webform component array.
$value: The POST data associated with the user input.
Return value
An array of values to be saved into the database. Note that this should be a numerically keyed array.
File
- ./
webform_phone.components.inc, line 321 - Webform Component information for a phone number field type
Code
function _webform_submit_phone($component, $value) {
$ccode = $component['extra']['country'];
if (phone_countries($ccode) !== NULL) {
if (isset($value) && !empty($value)) {
//Use 'phone' module to format the number
return format_phone_number($ccode, $value, $component['extra']);
}
}
return FALSE;
//If we haven't returned already, something failed.
}