1. Go to this page and download the library: Download cakedc/cakephp-datatables library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
<?= $this->Datatable->setFields([
[
'name' => 'title',
'links' => [
// Will produce a dynamic link with object data, i.e.
// <a href="/articles/view/' + obj.id + '">hard coded</a>
['url' => ['action' => 'view', 'extra' => ("/' + obj.id + '")], 'label' => 'hard coded'],
// Will produce a fixed link with a hard coded label, i.e.
// <a href="/articles/view/d">hard coded</a>
['url' => ['action' => 'view', 'd'], 'label' => 'hard coded'],
// Will produce a fixed link with a dynamic label, i.e.
// <a href="/articles/edit">' + obj.user_id + '</a>
['url' => ['action' => 'edit'], 'value' => 'obj.user_id'],
// Will produce a fixed link without an external URL in the href attribute, i.e.
// <a href="#">' + obj.user_id + '</a>
['url' => '#', 'value' => 'obj.user_id'],
]
],
]);
public function initialize(): void
{
parent::initialize();
...
if ($this->components()->has('Security')) {
$this->Security->setConfig('unlockedActions', ['list']);
}
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.