function location_taxonomize_af_element_submitted in Location Taxonomize 7.2
A submit handler for forms that contain an addressfield
1 string reference to 'location_taxonomize_af_element_submitted'
- location_taxonomize_af_process_address in location_taxonomize_af/
location_taxonomize_af.module - A #process callback function for the addressfield widget Here we make note of this field in the form_state array, and add a submit callback to the form that will handle the processing.
File
- location_taxonomize_af/
location_taxonomize_af.module, line 100
Code
function location_taxonomize_af_element_submitted($form, &$form_state) {
$lang = 'und';
// Act on values
$fields = $form_state['temporary']['addressfields'];
$items = array();
foreach ($fields as $field) {
$deltas = $form_state['values'][$field][$lang];
$actual_delta = 0;
foreach ($deltas as $delta) {
// Add the Administrative Area name, if possible
if (isset($form[$field][$lang][$actual_delta]['locality_block']['administrative_area']['#options'])) {
$options = $form[$field][$lang][$actual_delta]['locality_block']['administrative_area']['#options'];
$delta['administrative_area_name'] = $options[$delta['administrative_area']];
}
// Add the country name
$delta['country_name'] = location_taxonomize_get_country_name($delta['country']);
$items[] = $delta;
$actual_delta++;
}
}
// taxonomize
if (!empty($items)) {
location_taxonomize_taxonomize($items, $form, $form_state);
}
}