function panels_node_form in Panels 6.2
Same name and namespace in other branches
- 5.2 panels_node/panels_node.module \panels_node_form()
- 6.3 panels_node/panels_node.module \panels_node_form()
Implementation of hook_form().
File
- panels_node/
panels_node.module, line 168 - panels_node.module
Code
function panels_node_form(&$node, &$param) {
$form['panels_node']['#tree'] = TRUE;
if (!$node->nid) {
// Grab our selected layout from the $node, If it doesn't exist, try arg(3)
// and if that doesn't work present them with a list to pick from.
$panel_layout = isset($node->panel_layout) ? $node->panel_layout : arg(3);
if (empty($panel_layout)) {
return drupal_goto('node/add/panel/choose-layout');
}
panels_load_include('plugins');
$layout = panels_get_layout($panel_layout);
if (empty($layout)) {
return drupal_not_found();
}
$form['panels_node']['layout'] = array(
'#type' => 'value',
'#value' => $panel_layout,
);
}
$type = node_get_types('type', $node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
);
if (!empty($type->body_label)) {
$form['body'] = array(
'#type' => 'textarea',
'#title' => check_plain($type->body_label),
'#rows' => 10,
'#required' => TRUE,
'#description' => t('The teaser is a piece of text to describe when the panel is listed (such as when promoted to front page); the actual content will only be displayed on the full node view.'),
'#default_value' => $node->body,
);
}
// drupal_set_message('<pre>' . check_plain(var_export($node, true)) . '</pre>');
$css_id = '';
if (!empty($node->panels_node['css_id'])) {
$css_id = $node->panels_node['css_id'];
}
$form['panels_node']['css_id'] = array(
'#type' => 'textfield',
'#title' => t('CSS ID'),
'#size' => 30,
'#description' => t('An ID that can be used by CSS to style the panel.'),
'#default_value' => $css_id,
);
return $form;
}