fileupload_form
developer/examples/fileupload.module, строка 121
- Версии
- 5
fileupload_form(&$node)
Реализация hook_form()
.
Return an array of the form elements needed to edit this node.
Код
<?php
function fileupload_form(&$node) {
// Set form parameters so we can accept file uploads.
$form['#attributes'] = array('enctype' => 'multipart/form-data');
// standard node title
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => $node->title
);
// file upload field
$form['file'] = array(
'#type' => 'file',
'#title' => t('File'),
'#size' => 40,
'#default_value' => '',
);
if ($node->file->filepath) {
$form['file']['#description'] .= t('A file already exists, if you upload another file the current file will be replaced.');
}
if ($node->nid) {
// the validate function doesn't get a full copy of the node, only the
// data posted from the form. use this field to tell the validator
// the path of the node's current file.
$form['current_file'] = array(
'#type' => 'value',
'#value' => $node->file->filepath
);
}
return $form;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии