function openlayers_cck_field in Openlayers 6.2
Same name and namespace in other branches
- 6 modules/openlayers_cck/openlayers_cck.module \openlayers_cck_field()
Implementation of hook_field().
File
- modules/
openlayers_cck/ openlayers_cck.module, line 193 - This file holds the main Drupal hook functions and private functions for the openlayers_cck module.
Code
function openlayers_cck_field($op, &$node, $field, &$items, $teaser, $page) {
switch ($op) {
case 'validate':
// Check if field is valid WKT format
foreach ($items as $delta => $value) {
// @@TODO: validate WKT
// if the field is required, prevent the submission of empty geo
// collections, which break maps
if ($field['required']) {
if ($value[$field['type']] == 'GEOMETRYCOLLECTION()') {
form_set_error($field['field_name'], t('@name is required.', array(
'@name' => $field['widget']['label'],
)));
}
}
}
break;
}
}