Form altering certain CCK widget properties is tricky: adding and changing the size of an autocomplete textfield
This code (which is not called automatically but is a helper function for our hook_form_alter implementation) adds the suffix but does not change the forms size. Somehow these widget settings must get added later.
<?php
function biblioreference_alter_item(&$form, $key, $item, $fields) {
$field_name = strstr($key, 'field_');
if (isset($fields[$field_name]) && $fields[$field_name]['type'] == 'nodereference') {
$type = $form['type']['#value'];
$field = content_fields($field_name, $form['type']['#value']);
if ($field['widget']['type'] == 'biblioreference_autocomplete') {
// make the text field wider so the autocomplete looks better
$form[$key][0]['#size'] = 100;
// Add link to add new citation
$suffix = '<div class="pdbiblio-add-new">';
$suffix .= t('* If your reference is not in PD Biblio, <a href="@url" target="_BLANK">add a new citation in PDBiblio</a> manually. This link will take you to a new window. After creating the reference, please remember to add it to the article.', array('@url' => url('biblioreference/add/citation')));
$suffix .= '</div>';
$form[$key]['#suffix'] = $suffix;
}
}
}
?>
Comments
Post new comment