Hi there
I am trying to implement a new map coordinates field though I am having trouble getting the field values to save to the database as I cannot find the values I have entered through PHPmyadmin though I can see the table.
The map coordinate picker is working and fills the text area fine. However the field does not display when I view the node which is probably because the values are not saving to the DB. Also I am not sure if the hook_field_formatter functions are working. The code is an edited version of the field_example.module from 'examples' module.
my code:
in my .module file
<?php
function gmap_field_info() {
return array(
'gmap_coords' => array(
'label' => t('Map coords'),
'description' => t('A field composed of coords.'),
'default_widget' => 'gmap_coords_picker',
'default_formatter' => 'gmap_simple_text',
),
);
}
function gmap_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) {
if (!empty($item['coords'])) {
if (! preg_match('@^\:\.[0-9]{50}$@', $item['coords'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'field_example_invalid',
'message' => t('Coords must be in the format 128.45678:135.98764'),
);
}
}
}
}