function location_addanother_form_validate in Location 7.3
Same name and namespace in other branches
- 5.3 contrib/location_addanother/location_addanother.module \location_addanother_form_validate()
- 6.3 contrib/location_addanother/location_addanother.module \location_addanother_form_validate()
- 7.5 contrib/location_addanother/location_addanother.module \location_addanother_form_validate()
- 7.4 contrib/location_addanother/location_addanother.module \location_addanother_form_validate()
Validation function for "add another location" form.
File
- contrib/
location_addanother/ location_addanother.module, line 87 - "Add location from node view" functionality. Split from main location.module in version 3.
Code
function location_addanother_form_validate($form, &$form_state) {
// Load the stored node from form_state.
$node = $form_state['#node'];
// Load the content type's location settings to see if addanother is enabled.
$settings = variable_get('location_settings_node_' . $node->type, array());
$is_enabled = isset($settings['multiple']['location_addanother']) ? $settings['multiple']['location_addanother'] : FALSE;
// If addanother isn't enabled for this node type,
// or there's too many locations,
// or the user doesn't have access to add a location,
if (!$is_enabled || count($node->locations) >= variable_get('location_maxnum_' . $node->type, 0) || !node_access('update', $node)) {
// then give a useful error.
form_set_error('location', t("You don't have permission to add a location to this node, or the node has the maximum number of locations already."));
}
}