class DialogFormLink

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/ajax_forms_test/src/Controller/DialogFormLink.php \Drupal\ajax_forms_test\Controller\DialogFormLink

Test class to create dialog form link.

Hierarchy

Expanded class hierarchy of DialogFormLink

File

core/modules/system/tests/modules/ajax_forms_test/src/Controller/DialogFormLink.php, line 10

Namespace

Drupal\ajax_forms_test\Controller
View source
class DialogFormLink {
    
    /**
     * Builds an associative array representing a link that opens a dialog.
     *
     * @return array
     *   An associative array of link to a form to be opened.
     */
    public function makeDialogFormLink() {
        return [
            'dialog' => [
                '#type' => 'link',
                '#title' => 'Open form in dialog',
                '#url' => Url::fromRoute('ajax_forms_test.get_form'),
                '#attributes' => [
                    'class' => [
                        'use-ajax',
                    ],
                    'data-dialog-type' => 'dialog',
                ],
            ],
            'off_canvas' => [
                '#type' => 'link',
                '#title' => 'Open form in off canvas dialog',
                '#url' => Url::fromRoute('ajax_forms_test.get_form'),
                '#attributes' => [
                    'class' => [
                        'use-ajax',
                    ],
                    'data-dialog-type' => 'dialog',
                    'data-dialog-renderer' => 'off_canvas',
                ],
            ],
            '#attached' => [
                'library' => [
                    'core/drupal.dialog.ajax',
                ],
            ],
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
DialogFormLink::makeDialogFormLink public function Builds an associative array representing a link that opens a dialog.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.