0.5
0.5.0.0CakePHP3 variables in JS
The Requires
- php >=5.4.16
- cakephp/cakephp ~3.0
The Development Requires
0.3
0.3.0.0CakePHP3 variables in JS
The Requires
- php >=5.4.16
- cakephp/cakephp ~3.0
The Development Requires
Wallogit.com
2017 © Pedro Peláez
CakePHP3 variables in JS
You can easy to pass CakePHP4 variables to JS in View., (*1)
In Application.php, (*2)
<?php
$this->addPlugin('Pack');
In controller., (*3)
loadComponent('Pack.Pack');
}
...
}
```
In layout php or template php.
```php
= $this->Pack->render();?>
Just set variables in your controller., (*4)
<?php
$entity = $this->Hoge->get($id);
$array = [...];
$this->Pack->set('entity', $entity);
$this->Pack->set('array', $array);
## OR ##
$this->Pack->set(compact('entity', 'array'));
Just get the variables in your JS in view., (*5)
Pack.entity;
Pack.array;
example, (*6)
In controller, (*7)
$this->Pack->rename('Hoge');
$this->Pack->set('array', $array);
In js, (*8)
Hoge.array;
CakePHP3 variables in JS
CakePHP3 variables in JS