function DialogFormLink::makeDialogFormLink

Same name and namespace in other branches
  1. 10 core/modules/system/tests/modules/ajax_forms_test/src/Controller/DialogFormLink.php \Drupal\ajax_forms_test\Controller\DialogFormLink::makeDialogFormLink()

Builds an associative array representing a link that opens a dialog.

Return value

array An associative array of link to a form to be opened.

1 string reference to 'DialogFormLink::makeDialogFormLink'
ajax_forms_test.routing.yml in core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml
core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml

File

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

Class

DialogFormLink
Test class to create dialog form link.

Namespace

Drupal\ajax_forms_test\Controller

Code

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',
      ],
    ],
  ];
}

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