public function PanelizerEntityNode::hook_form_alter in Panelizer 7.3
Same name and namespace in other branches
- 7.2 plugins/entity/PanelizerEntityNode.class.php \PanelizerEntityNode::hook_form_alter()
Implements a delegated hook_form_alter.
We want to add Panelizer settings for the bundle to the node type form.
Overrides PanelizerEntityDefault::hook_form_alter
File
- plugins/
entity/ PanelizerEntityNode.class.php, line 155 - Class for the Panelizer node entity plugin.
Class
- PanelizerEntityNode
- Panelizer Entity node plugin class.
Code
public function hook_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'node_type_form') {
if (isset($form['#node_type'])) {
$bundle = $form['#node_type']->type;
$this
->add_bundle_setting_form($form, $form_state, $bundle, array(
'type',
));
}
// Additional workflow options when Workbench Moderation is enabled.
if (module_exists('workbench_moderation')) {
// It's now possible to disable revision creation through the Panelizer
// interface.
$form['workflow']['node_options']['#options']['panelizer'] = t('Enable Panelizer revisions');
// Disable the 'revision' checkbox when the 'moderation' checkbox is
// checked, so that moderation can not be enabled unless revisions are
// enabled.
$form['workflow']['node_options']['revision']['#states'] = array(
'disabled' => array(
':input[name="node_options[panelizer]"]' => array(
'checked' => FALSE,
),
),
);
// Disable the 'moderation' checkbox when the 'revision' checkbox is
// not checked, so that revisions can not be turned off without also
// turning off moderation.
$form['workflow']['node_options']['panelizer']['#description'] = t('Revisions must be enabled in order to create revisions from within Panelizer.');
$form['workflow']['node_options']['panelizer']['#states'] = array(
'disabled' => array(
':input[name="node_options[revision]"]' => array(
'checked' => FALSE,
),
),
);
}
}
}