function spaces_casetracker_form_alter in Spaces 5.2
Same name and namespace in other branches
- 5 spaces_casetracker/spaces_casetracker.module \spaces_casetracker_form_alter()
Implementation of hook_form_alter()
File
- spaces_casetracker/
spaces_casetracker.module, line 58
Code
function spaces_casetracker_form_alter($form_id, &$form) {
switch ($form_id) {
case 'casetracker_basic_case_node_form':
case 'comment_form':
// Implement batch creation
if ($form_id == 'casetracker_basic_case_node_form') {
$form['batch'] = array(
'#type' => 'submit',
'#value' => t('Submit + create another'),
'#weight' => 50,
);
$form['#submit']['_spaces_casetracker_node_form_submit'] = array();
array_reverse($form['#submit']);
}
$space = spaces_get_space();
// Remove disallowed projects.
if (isset($form['casetracker_project_information'])) {
$pid = $form_id == 'casetracker_basic_case_node_form' ? 'pid' : 'prid';
// "sigh." see casetracker_form_alter() for details.
if (is_array($form['casetracker_project_information'][$pid]['#options'])) {
foreach ($form['casetracker_project_information'][$pid]['#options'] as $key => $value) {
$node = array(
'nid' => $key,
'type' => 'casetracker_basic_project',
);
$groups = og_get_node_groups((object) $node);
if (!array_key_exists($space->sid, $groups)) {
unset($form['casetracker_project_information'][$pid]['#options'][$key]);
}
}
}
}
// Change the autocomplete callback to limit by group
$form['casetracker_case_information']['assign_to']['#autocomplete_path'] = 'spaces/team/autocomplete/' . $space->sid;
break;
// Views filters
// Handle exposed casetracker filters, sadly case tracker is dumb to og.
case 'views_filters':
switch ($form['#view_name']) {
case 'spaces_cases_my':
case 'spaces_cases_byproject':
case 'spaces_cases_bycreated':
unset($form['filter0']['#options']);
$form['filter0']['#options'] = spaces_casetracker_project_options();
break;
case 'spaces_cases_byuser':
unset($form['filter0']['#options']);
$form['filter0']['#options'] = spaces_casetracker_user_options();
break;
case 'spaces_cases_filter':
unset($form['filter0']['#options']);
$form['filter0']['#options'] = spaces_casetracker_project_options();
unset($form['filter1']['#options']);
$form['filter1']['#options'] = spaces_casetracker_user_options();
break;
}
break;
}
}