function sheetnode_form in Sheetnode 7.2
Same name and namespace in other branches
- 5 sheetnode.module \sheetnode_form()
- 6 sheetnode.module \sheetnode_form()
- 7 sheetnode.module \sheetnode_form()
Implements hook_form().
File
- ./
sheetnode.module, line 145 - Module file for the sheetnode module.
Code
function sheetnode_form($node, &$form_state) {
$types = node_type_get_types();
$type = $types['sheetnode'];
// Generate the default title.
$form = node_content_form(!empty($node) ? $node : 'sheetnode', $form_state);
// SocialCalc sheet.
if (!empty($form_state['input']['sheetnode']['value'])) {
$value = $form_state['input']['sheetnode']['value'];
$nid = @$node->nid;
}
elseif (!empty($node->nid)) {
$value = $node->sheetnode['value'];
$nid = $node->nid;
}
elseif (!empty($node->clone_from_original_nid)) {
// Support node_clone.module.
$original_node = node_load($node->clone_from_original_nid);
$value = $original_node->sheetnode['value'];
$nid = $node->clone_from_original_nid;
}
else {
$value = '';
$nid = NULL;
}
$output = _sheetnode_inject(drupal_clean_css_identifier('sheetnode-' . (empty($node->nid) ? 'new' : $node->nid)), 'sheetnode', $value, drupal_clean_css_identifier('edit-sheetnode-value'), array(
'entity-type' => 'node',
'oid' => $nid,
));
$form['sheetnode'] = array(
'#tree' => TRUE,
'#weight' => -1,
'socialcalc' => array(
'#markup' => $output,
),
'value' => array(
'#type' => 'hidden',
'#attributes' => array(
'id' => 'edit-sheetnode-value',
),
),
);
// Template.
if (user_access('create sheetnode template')) {
$form['sheetnode']['template'] = array(
'#type' => 'textfield',
'#title' => t('Save as template'),
'#description' => t('When saving this sheet, also keep a copy under the name you specify here. Later, this copy can be used as a template for other sheets.'),
'#required' => FALSE,
);
}
return $form;
}