You are here

function location_node_settings_validate in Location 6.3

Same name and namespace in other branches
  1. 5.3 location_node.module \location_node_settings_validate()
  2. 5 location.module \location_node_settings_validate()
  3. 7.3 location_node.module \location_node_settings_validate()
  4. 7.4 location_node.module \location_node_settings_validate()

Validation function for node settings form. Logically, the default number of locations per node cannot be bigger than the max locations.

@ingroup $form

1 string reference to 'location_node_settings_validate'
location_node_form_node_type_form_alter in ./location_node.module
Alter the node_type_form form.

File

./location_node.module, line 167
Associate locations with nodes.

Code

function location_node_settings_validate($form, &$form_state) {
  if (!empty($form_state['values']['location_settings']['multiple']['max']) && empty($form_state['values']['location_settings']['multiple']['add'])) {
    form_error($form['location_settings']['multiple']['add'], t("You must have at least one empty location form enabled if you are going to allow locations to be submitted for nodes of this content type. If you don't intend to allow locations to be submitted for nodes of this content type, set the maximum number of locations allowed for this content type to 0."));
  }
  elseif ($form_state['values']['location_settings']['multiple']['max'] > 0) {
    if ($form_state['values']['location_settings']['multiple']['add'] > $form_state['values']['location_settings']['multiple']['max']) {
      form_error($form['location_settings']['multiple']['add'], t("You can't show more empty location forms than the maximum number of locations allowed for this content type."));
    }
  }
}