function location_taxonomy_form_alter in Location 7.4
Same name and namespace in other branches
- 6.3 contrib/location_taxonomy/location_taxonomy.module \location_taxonomy_form_alter()
- 7.5 contrib/location_taxonomy/location_taxonomy.module \location_taxonomy_form_alter()
- 7.3 contrib/location_taxonomy/location_taxonomy.module \location_taxonomy_form_alter()
Implementation of hook_form_alter().
File
- contrib/
location_taxonomy/ location_taxonomy.module, line 52 - Associate locations with taxonomy terms.
Code
function location_taxonomy_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'taxonomy_form_vocabulary') {
$settings = array();
if (isset($form['vid'])) {
$settings = variable_get('location_taxonomy_' . $form['vid']['#value'], array());
}
$form['location_settings'] = location_settings($settings);
}
if ($form_id == 'taxonomy_form_term') {
$vid = $form['vid']['#value'];
$settings = variable_get('location_taxonomy_' . $vid, FALSE);
if ($settings && $settings['multiple']['max']) {
$locations = array();
if (isset($form['tid']) && $form['tid']['#value']) {
$locations = location_load_locations('taxonomy:' . $form['tid']['#value'], 'genid');
}
$form['locations'] = location_form($settings, $locations);
}
}
// Move the Save and Delete buttons down below our additions.
if ($form_id == 'taxonomy_form_vocabulary' || $form_id == 'taxonomy_form_term') {
if (isset($form['submit']['#weight'])) {
$form['submit']['#weight']++;
}
else {
$form['submit']['#weight'] = 1;
}
if (isset($form['delete'])) {
if (isset($form['delete']['#weight'])) {
$form['delete']['#weight'] += 2;
}
else {
$form['delete']['#weight'] = 2;
}
}
}
}