- <?php
- * @file
- * Hook implementations for the Vertical Tabs Example module.
- */
-
- * @defgroup vertical_tabs_example Example: Vertical Tabs
- * @ingroup examples
- * @{
- * This example demonstrates the vertical tabs functionality.
- *
- * This example does not cover how to save or load a custom setting, and only
- * deals with the elements visibility and summary in the tab.
- *
- * @see vertical_tabs_example.js
- */
-
- * Implements hook_menu().
- *
- * Gives us a simple explanation page.
- */
- function vertical_tabs_example_menu() {
- $items['examples/vertical_tabs'] = array(
- 'title' => 'Vertical tabs example',
- 'description' => 'Shows how vertical tabs can best be supported by a custom module',
- 'page callback' => '_vertical_tabs_example_explanation',
- 'access callback' => TRUE,
- );
- return $items;
- }
-
- * Implements hook_form_alter().
- *
- * Adds custom fieldset to the node form, and attach ajax behaviour for vertical
- * panels to update the settings description.
- *
- * @see vertical_tabs_example.js
- */
- function vertical_tabs_example_form_alter(&$form, $form_state, $form_id) {
-
- if (isset($form['#node']) && $form['#node']->type . '_node_form' == $form_id) {
-
- $form['vertical_tabs_example'] = array(
- '#type' => 'fieldset',
- '#title' => t('Example vertical tab'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- '#tree' => TRUE,
-
- '#weight' => -99,
-
-
- '#group' => 'additional_settings',
-
-
-
-
- '#attached' => array(
- 'js' => array(
- 'vertical-tabs' => backdrop_get_path('module', 'vertical_tabs_example') . '/vertical_tabs_example.js',
- ),
- ),
- );
-
-
-
-
-
-
- $form['vertical_tabs_example']['enabled'] = array(
- '#type' => 'checkbox',
- '#title' => t('Change this setting'),
- '#default_value' => FALSE,
- );
-
-
-
-
- $form['vertical_tabs_example']['vertical_tabs_examplecontainer'] = array(
- '#type' => 'container',
- '#parents' => array('vertical_tabs_example'),
- '#states' => array(
- 'invisible' => array(
-
- 'input[name="vertical_tabs_example[enabled]"]' => array('checked' => FALSE),
- ),
- ),
- );
-
-
-
- $form['vertical_tabs_example']['vertical_tabs_examplecontainer']['custom_setting'] = array(
- '#type' => 'textfield',
- '#title' => t('Use this setting instead'),
- '#default_value' => 'I am a setting with a summary',
- '#description' => t('As you type into this field, the summary will be updated in the tab.'),
- );
- }
- }
-
- * Simple explanation page.
- */
- function _vertical_tabs_example_explanation() {
- return t("<p>The Vertical Tabs Example shows how a custom module can add a vertical tab to a node edit form, and support its summary field with JavaScript.</p><p>To see the effects of this module, <a href='!node_add'>add a piece of content</a> and look at the set of tabs at the bottom. We've added one called 'Example vertical tab.'</p>", array('!node_add' => url('node/add')));
- }
- * @} End of "defgroup vertical_tabs_example".
- */