function biblio_form_alter in Bibliography Module 6
Same name and namespace in other branches
- 5 biblio.module \biblio_form_alter()
- 6.2 biblio.module \biblio_form_alter()
- 7.2 biblio.module \biblio_form_alter()
File
- ./
biblio.module, line 1100
Code
function biblio_form_alter(&$form, $form_state, $form_id) {
if ($form_id == "biblio_node_form") {
// this next bit is to remove all the form elements execpt the pub type select box the first time through
if (!isset($form_state['values']['biblio_type']) && empty($form['biblio_type']['#default_value']) && empty($form_state['post']['biblio_type']) && empty($form_state['submitted']) && empty($form['vid']['#value'])) {
foreach (element_children($form) as $form_element) {
if (strstr($form_element, 'biblio_')) {
continue;
}
if ($form[$form_element]['#type'] == 'value' || $form[$form_element]['#type'] == 'hidden' || $form[$form_element]['#type'] == 'token') {
continue;
}
$form[$form_element]['#access'] = FALSE;
}
}
else {
if (isset($form['menu']['#weight']) && $form['menu']['#weight'] < 20) {
$form['menu']['#weight'] = 20;
}
if (isset($form['book']['#weight']) && $form['book']['#weight'] < 20) {
$form['book']['#weight'] = 20;
}
if (isset($form['taxonomy'])) {
if (!isset($form['taxonomy']['#title'])) {
$form['taxonomy'] += array(
'#type' => 'fieldset',
'#title' => t('Vocabularies'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
}
$form['taxonomy']['#description'] = t('Select taxonomy terms which will be related to this %biblio_base_title entry.', array(
'%biblio_base_title' => variable_get('biblio_base_title', 'Biblio'),
));
$form['taxonomy']['copy_to_biblio'] = array(
'#type' => 'checkbox',
'#title' => t('Copy these terms to the biblio keyword database'),
'#return_value' => 1,
'#default_value' => variable_get('biblio_copy_taxo_terms_to_keywords', 0),
'#description' => t('If this option is selected, the selected taxonomy terms will be copied to the %biblio_base_title keyword database and be displayed as keywords (as well as taxonomy terms) for this entry.', array(
'%biblio_base_title' => variable_get('biblio_base_title', 'Biblio'),
)),
);
}
$kw_vocab = variable_get('biblio_keyword_vocabulary', 0);
$freetagging = variable_get('biblio_keyword_freetagging', 0);
if ($freetagging && $kw_vocab && isset($form['taxonomy']['tags'][$kw_vocab])) {
unset($form['taxonomy']['tags'][$kw_vocab]);
}
}
}
return $form;
}