function biblio_form_alter in Bibliography Module 5
Same name and namespace in other branches
- 6.2 biblio.module \biblio_form_alter()
- 6 biblio.module \biblio_form_alter()
- 7.2 biblio.module \biblio_form_alter()
File
- ./
biblio.module, line 1573
Code
function biblio_form_alter($form_id, &$form) {
global $form_values;
if ($form_id == "biblio_node_form") {
if (!empty($form['#node']->biblio_type)) {
$type = $form['#node']->biblio_type;
}
if (!empty($form['#post']['biblio_type'])) {
$type = $form['#post']['biblio_type'];
}
//$type = $form['#post']['biblio_type'] ? $form['#post']['biblio_type']:;
if ($type > 0) {
$form['title']['#type'] = 'textfield';
if (variable_get('biblio_input_full_text', 1)) {
$form['body']['#type'] = 'textarea';
}
$result = db_query('SELECT * FROM {biblio_fields} as b ORDER BY b.weight ASC');
while ($row = db_fetch_array($result)) {
$fields[$row['fid']] = $row;
if ($row['common']) {
$form[$row['name']]['#type'] = $row['type'];
}
}
$result = db_query('SELECT b.*, c.name, c.type FROM {biblio_type_details} as b INNER JOIN {biblio_fields} as c ON b.fid = c.fid where tid= %d ORDER BY b.weight ASC', $type);
while ($row = db_fetch_array($result)) {
$type_fields[$row['fid']] = $row;
$form[$row['name']]['#type'] = $row['type'];
}
if (count($type_fields)) {
// now merge the customizations with the main field array
foreach ($type_fields as $key => $value) {
$fields[$key] = array_merge($fields[$key], $value);
}
}
foreach ($fields as $key => $fld) {
$form[$fld['name']] = array_merge($form[$fld['name']], array(
'#default_value' => $form['#node']->{$fld}['name'],
'#title' => check_plain($fld['title']),
'#required' => $fld['required'],
'#size' => $fld['size'],
'#maxlength' => $fld['maxsize'],
'#weight' => $fld['weight'] / 10,
'#description' => check_plain($fld['hint']),
));
// end array_merge
}
//end foreach
$form['biblio_keywords']['#description'] = t("Separate key words with a <b>@sep</b> character", array(
'@sep' => variable_get('biblio_keyword_sep', ','),
));
}
//endif type > 0
}
//endif ($form_id == 'biblio_node_form...
return $form;
}