Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions geofield.elements.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ define('GEOFIELD_NAUTICAL_MILES', 3444);
/**
* Implements hook_element_info().
*/

function geofield_element_info() {
return array(
'geofield_latlon' => array(
Expand All @@ -47,6 +46,7 @@ function geofield_element_info() {
'#element_validate' => array('geofield_latlon_element_validate'),
'#theme' => array('geofield_latlon'),
'#theme_wrappers' => array('fieldset'),
'#value_callback' => 'geofield_latlon_element_value_callback',
),
'geofield_bounds' => array(
'#input' => TRUE,
Expand All @@ -65,9 +65,24 @@ function geofield_element_info() {
}

/**
* Process function for geofield_latlon.
* Custom value callback for 'geofield_latlon' elements.
*/
function geofield_latlon_element_value_callback($element, $input, &$form_state) {
// Silently discard invalid data type. This prevents TypeError when building
// the form. For example triggered by viwes exposed form GET data.
if (is_string($input)) {
unset($form_state['input']['field_geofield_distance']['origin']);
return array(
'lat' => '',
'lon' => '',
);
}
return $input;
}

/**
* Process function for geofield_latlon.
*/
function geofield_latlon_element_process($element, &$form_values) {
$element['#tree'] = TRUE;
$element['#input'] = TRUE;
Expand Down
Loading