function panels_node_hook_form in Panels 7.3
Implementation of hook_form().
File
- panels_node/
panels_node.module, line 156 - panels_node.module
Code
function panels_node_hook_form(&$node, &$form_state) {
ctools_include('plugins', 'panels');
$form['panels_node']['#tree'] = TRUE;
if (empty($node->nid) && arg(0) == 'node' && arg(1) == 'add') {
// 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)) {
drupal_goto('node/add/panel/choose-layout', array(
'query' => drupal_get_query_parameters(),
));
}
$layout = panels_get_layout($panel_layout);
if (empty($layout)) {
return MENU_NOT_FOUND;
}
$form['panels_node']['layout'] = array(
'#type' => 'value',
'#value' => $panel_layout,
);
}
$type = node_type_get_type($node);
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#required' => TRUE,
'#default_value' => $node->title,
);
$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,
);
// Support for different rendering pipelines
// Mostly borrowed from panel_context.inc.
$pipelines = panels_get_renderer_pipelines();
$options = array();
foreach ($pipelines as $name => $pipeline) {
$options[$name] = check_plain($pipeline->admin_title) . '<div class="description">' . check_plain($pipeline->admin_description) . '</div>';
}
$form['panels_node']['pipeline'] = array(
'#type' => 'radios',
'#options' => $options,
'#title' => t('Renderer'),
'#default_value' => isset($node->panels_node['pipeline']) ? $node->panels_node['pipeline'] : variable_get('panels_renderer_default', 'standard'),
);
return $form;
}