diff --git a/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php b/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php index cc732dd..0a14bbc 100644 --- a/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php +++ b/vertical_tabs_example/src/Controller/VerticalTabsExampleController.php @@ -14,7 +14,7 @@ class VerticalTabsExampleController { use DescriptionTemplateTrait; /** - * {%inheritdoc}. + * {@inheritdoc} */ protected function getModuleName() { return 'vertical_tabs_example'; diff --git a/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php b/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php index 735a3c0..3d31aa2 100644 --- a/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php +++ b/vertical_tabs_example/src/Tests/VerticalTabsExampleTest.php @@ -18,7 +18,7 @@ class VerticalTabsExampleTest extends WebTestBase { * * @var array */ - public static $modules = array('node' , 'vertical_tabs_example'); + public static $modules = ['vertical_tabs_example']; /** * Tests the menu paths defined in vertical_tabs_example module. diff --git a/vertical_tabs_example/templates/description.html.twig b/vertical_tabs_example/templates/description.html.twig index c0a7fad..083113e 100644 --- a/vertical_tabs_example/templates/description.html.twig +++ b/vertical_tabs_example/templates/description.html.twig @@ -8,8 +8,11 @@ {% set content_url = path('node.add_page') %} {% trans %} -
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. To see the -effects of this module, add a piece of content -and look at the set of tabs beside.
+The Vertical Tabs Example shows how a custom module can add a vertical tab to + a node edit form and update its summary field with JavaScript.
+To see the effects of this module, add a piece of + content and look at the set of tabs beside.
+Note that this behavior won't work with the "Seven" administration theme that + is enabled by default. You'll need to change the administration theme to be + another one.
{% endtrans %} diff --git a/vertical_tabs_example/vertical_tabs_example.info.yml b/vertical_tabs_example/vertical_tabs_example.info.yml index 73fa8de..8cc15d2 100644 --- a/vertical_tabs_example/vertical_tabs_example.info.yml +++ b/vertical_tabs_example/vertical_tabs_example.info.yml @@ -4,4 +4,5 @@ description: 'Show how to use vertical tabs for enhancing user experience.' package: Example modules core: 8.x dependencies: - - examples + - drupal:node + - examples:examples diff --git a/vertical_tabs_example/vertical_tabs_example.module b/vertical_tabs_example/vertical_tabs_example.module index eedd8ef..72292c0 100644 --- a/vertical_tabs_example/vertical_tabs_example.module +++ b/vertical_tabs_example/vertical_tabs_example.module @@ -11,6 +11,10 @@ use Drupal\Core\Form\FormStateInterface; * Implements hook_form_alter(). */ function vertical_tabs_example_form_node_form_alter(array &$form, FormStateInterface $form_state) { + // Vertical tabs provide its most usable appearance when they are used to + // include a summary of the information contained in the details. To do this, + // we attach additional JavaScript to handle changing the summary when form + // settings are changed. $form['#attached']['library'][] = 'vertical_tabs_example/vertical_tabs_example'; // Create a details field that will be included in the vertical tab. $form['vertical_tabs_example'] = [ @@ -24,11 +28,8 @@ function vertical_tabs_example_form_node_form_alter(array &$form, FormStateInter // The #group value must match the name of the vertical tabs element. // In most cases, this is 'additional_settings'. '#group' => 'advanced', - // Vertical tabs provide its most usable appearance when they are used to - // include a summary of the information contained in the details. To do - // this, we attach additional JavaScript to handle changing the summary - // when form settings are changed. - ]; + ]; + // The form elements below provide a demonstration of how a details // summary can be displayed in a collapsed tab. // @@ -39,23 +40,23 @@ function vertical_tabs_example_form_node_form_alter(array &$form, FormStateInter '#title' => t('Change this setting'), '#default_value' => FALSE, ]; - + // This container will be used to store the whole form for our custom - // settings. This way, showing/hiding the form using javascript is easier, + // settings. This way, showing/hiding the form using JavaScript is easier, // as only one element should be set visible. $form['vertical_tabs_example']['vertical_tabs_examplecontainer'] = [ '#type' => 'container', '#parents' => ['vertical_tabs_example'], '#states' => [ - 'invisible' => [ + 'invisible' => [ // If the checkbox is not enabled, show the container. - 'input[name="vertical_tabs_example[enabled]"]' => ['checked' => FALSE], - ], + 'input[name="vertical_tabs_example[enabled]"]' => ['checked' => FALSE], + ], ], ]; - - // The string of this textfield will be shown as summary in the vertical - // tab. + + // The string of this textfield will be shown as summary in the vertical + // tab. $form['vertical_tabs_example']['vertical_tabs_examplecontainer']['custom_setting'] = [ '#type' => 'textfield', '#title' => t('Use this setting instead'),