function document_form in Document 6
Same name and namespace in other branches
- 7 document.module \document_form()
- 8.x document.module \document_form()
Implementation of hook_form().
File
- ./
document.module, line 141
Code
function document_form(&$node, $form_state) {
$type = node_get_types('type', $node);
$form = array();
$form['#attributes'] = array(
'enctype' => 'multipart/form-data',
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
'#weight' => -5,
);
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
$form['document_edit_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Add Document'),
'#weight' => -4,
'#description' => t('Upload new document. Please note that the document would be would be visible after administrators have published it.'),
);
if ($node->nid && user_access('moderate document')) {
$form['document_edit_fieldset']['document_current'] = array(
'#type' => 'item',
'#title' => t('Current Document Path'),
'#value' => $node->document_url,
'#description' => t('Path to the document associated to this node for the current revision.'),
);
}
$form['document_edit_fieldset']['document_filepath'] = array(
'#type' => 'file',
'#title' => t('Select Document'),
'#description' => t('Document to upload. <b>This document should only be specified either while creating a new node, or while creating a revision for an existing node. The document will not be saved while updating an existing node, if a new revision is not created for the node.</b>'),
);
if (variable_get('document_allow_external', FALSE)) {
$form['document_edit_fieldset']['document_external_url'] = array(
'#type' => 'textfield',
'#title' => t('External Document Url'),
'#default_value' => isset($node->document_url) && $node->document_external == DOCUMENT_EXTERNAL ? $node->document_url : '',
'#description' => t('External Url to the document. <b>You should either specify this url or upload a document. The document would not be created in case you specify both.</b>'),
);
}
$form['document_edit_fieldset']['document_author'] = array(
'#type' => 'textfield',
'#required' => TRUE,
'#title' => t('Document Author(s)'),
'#default_value' => isset($node->document_author) ? $node->document_author : '',
'#description' => t('A comma separated list of Authors'),
);
$form['document_edit_fieldset']['document_year'] = array(
'#type' => 'select',
'#options' => drupal_map_assoc(array_reverse(document_get_years())),
'#required' => TRUE,
'#title' => t('Year of Publication'),
'#default_value' => isset($node->document_year) ? $node->document_year : '',
'#description' => t('Year of Publication'),
);
// $form['document_edit_fieldset']['document_type'] = array(
// '#type' => 'select',
// '#options' => document_get_types(FALSE),
// '#required' => TRUE,
// '#title' => t('Document Type'),
// '#default_value' => isset($node->document_type) ? $node->document_type : '',
// '#description' => t('Document Type'));
$form['document_edit_fieldset']['document_keywords'] = array(
'#type' => 'textarea',
'#rows' => 5,
'#title' => 'Keywords',
'#description' => t('Comma separated list of key terms associated with the document.'),
'#default_value' => isset($node->document_keywords) ? $node->document_keywords : '',
);
return $form;
}