function document_form in Document 8.x
Same name and namespace in other branches
- 6 document.module \document_form()
- 7 document.module \document_form()
Implementation of hook_form().
File
- ./
document.module, line 152
Code
function document_form(&$node, $form_state) {
$type = node_type_get_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['document_abstract'] = array(
'#type' => 'textarea',
'#rows' => '5',
'#title' => t('Abstract'),
'#weight' => -4,
'#default_value' => isset($node->document_abstract) ? $node->document_abstract : '',
'#description' => 'Add Template',
);
$form['document_edit_fieldset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Add Document'),
'#weight' => -2,
'#description' => t('Upload new document. Please note that the document will be visible after administrators have published it.'),
);
if (isset($node->nid) && $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_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' => t('Keywords'),
'#description' => t('Comma separated list of key terms associated with the document.'),
'#default_value' => isset($node->document_keywords) ? $node->document_keywords : '',
);
$form['document_edit_fieldset']['document_filepath'] = array(
'#type' => 'file',
'#title' => t('Select Document'),
'#default_value' => isset($node->document_url) ? $node->document_url : '',
'#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>'),
);
return $form;
}