function upload_form_alter in Drupal 4
Same name and namespace in other branches
- 5 modules/upload/upload.module \upload_form_alter()
- 6 modules/upload/upload.module \upload_form_alter()
File
- modules/
upload.module, line 265 - File-handling and attaching files to nodes.
Code
function upload_form_alter($form_id, &$form) {
if (isset($form['type'])) {
if ($form['type']['#value'] . '_node_settings' == $form_id) {
$form['workflow']['upload_' . $form['type']['#value']] = array(
'#type' => 'radios',
'#title' => t('Attachments'),
'#default_value' => variable_get('upload_' . $form['type']['#value'], 1),
'#options' => array(
t('Disabled'),
t('Enabled'),
),
);
}
$node = $form['#node'];
if ($form['type']['#value'] . '_node_form' == $form_id && variable_get("upload_{$node->type}", TRUE) && user_access('upload files')) {
drupal_add_js('misc/progress.js');
drupal_add_js('misc/upload.js');
// Attachments fieldset
$form['attachments'] = array(
'#type' => 'fieldset',
'#title' => t('File attachments'),
'#collapsible' => TRUE,
'#collapsed' => empty($node->files),
'#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
'#prefix' => '<div class="attachments">',
'#suffix' => '</div>',
'#weight' => 30,
);
// Wrapper for fieldset contents (used by upload JS).
$form['attachments']['wrapper'] = array(
'#prefix' => '<div id="attach-wrapper">',
'#suffix' => '</div>',
);
$form['attachments']['wrapper'] += _upload_form($node);
$form['#attributes']['enctype'] = 'multipart/form-data';
}
}
}