Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- debug($this->request->data):
- [
- 'users' => [
- (int) 0 => [
- '_joinData' => [
- 'rank' => '0'
- ]
- ],
- (int) 1 => [
- '_joinData' => [
- 'rank' => '0'
- ]
- ]
- ]
- ]
- VIEW:
- <?= $this->Form->create($association) ?>
- <?php $i = 0; ?>
- <?php foreach ($association->users as $user) : ?>
- <tr>
- <td><?= $user->username ?></td>
- <td><?= $user->_joinData->created; ?></td>
- <td>
- <?= $this->Form->select('users.' . $i . '._joinData.rank', ['options' => ['0' => 'User', '1' => 'Author']]); ?></td>
- <?php $i = $i + 1; ?>
- </tr>
- <?php endforeach ?>
- CONTROLLER:
- $association = $this->Associations->get($id, [
- 'contain' => ['Users']
- ]);
- if ($this->request->is(['patch', 'post', 'put'])) {
- $association = $this->Associations->patchEntity($association, $this->request->data, ['associated' => ['Users' => ['validate' => false]]]);
- debug($this->request->data);
- debug($association);
- die();
- if ($this->Associations->save($association, ['associated' => ['Users' => ['validate' => false]]])) {
- $this->Flash->success(__('Your changes have been saved.'));
- return $this->redirect(['action' => 'index']);
- } else {
- $this->Flash->error(__('Your changes could not be saved. Please, try again.'));
- }
- }
- $this->set('association', $association);
- $this->set('_serialize', ['association']);
- debug:
- object(App\Model\Entity\Association) {
- 'id' => (int) 1,
- 'name' => '123',
- 'users' => [
- (int) 0 => object(App\Model\Entity\User) {
- '_joinData' => object(App\Model\Entity\UserAssociation) {
- 'rank' => (int) 0,
- '[new]' => true,
- '[accessible]' => [
- '*' => true
- ],
- '[dirty]' => [
- 'rank' => true
- ],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'UserAssociation'
- },
- '[new]' => true,
- '[accessible]' => [
- '*' => true,
- '_joinData' => true
- ],
- '[dirty]' => [
- '_joinData' => true
- ],
- '[original]' => [
- '_joinData' => [
- 'rank' => '0'
- ]
- ],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'Users'
- },
- (int) 1 => object(App\Model\Entity\User) {
- '_joinData' => object(App\Model\Entity\UserAssociation) {
- 'rank' => (int) 0,
- '[new]' => true,
- '[accessible]' => [
- '*' => true
- ],
- '[dirty]' => [
- 'rank' => true
- ],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'UserAssociation'
- },
- '[new]' => true,
- '[accessible]' => [
- '*' => true,
- '_joinData' => true
- ],
- '[dirty]' => [
- '_joinData' => true
- ],
- '[original]' => [
- '_joinData' => [
- 'rank' => '0'
- ]
- ],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'Users'
- }
- ],
- '[new]' => false,
- '[accessible]' => [
- '*' => true
- ],
- '[dirty]' => [
- 'users' => true
- ],
- '[original]' => [
- 'users' => [
- (int) 0 => object(App\Model\Entity\User) {
- 'id' => (int) 2,
- 'username' => 'name',
- 'password' => '',
- 'email' => '',
- 'img' => 'users/blank-profile-picture.png',
- 'created' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-02-04T00:00:00+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'modified' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-09-27T14:17:20+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'role' => 'admin',
- 'api_key' => '',
- 'api_key_plain' => '',
- 'verified' => true,
- 'banned' => false,
- 'last_login' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-09-27T14:17:20+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- '_joinData' => object(App\Model\Entity\UserAssociation) {
- 'user_id' => (int) 2,
- 'id' => (int) 0,
- 'association_id' => (int) 1,
- 'created' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-09-15T06:00:00+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'rank' => (int) 0,
- '[new]' => false,
- '[accessible]' => [
- '*' => true
- ],
- '[dirty]' => [],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'UserAssociation'
- },
- '[new]' => false,
- '[accessible]' => [
- '*' => true,
- '_joinData' => true
- ],
- '[dirty]' => [],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'Users'
- },
- (int) 1 => object(App\Model\Entity\User) {
- 'id' => (int) 13,
- 'username' => 'random username',
- 'password' => '',
- 'email' => '',
- 'img' => '',
- 'created' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-05-06T10:39:02+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'modified' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-05-06T10:46:58+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'role' => 'user',
- 'api_key' => '',
- 'api_key_plain' => '',
- 'verified' => true,
- 'banned' => false,
- 'last_login' => null,
- '_joinData' => object(App\Model\Entity\UserAssociation) {
- 'user_id' => (int) 13,
- 'id' => (int) 1,
- 'association_id' => (int) 1,
- 'created' => object(Cake\I18n\FrozenTime) {
- 'time' => '2016-09-12T06:00:00+00:00',
- 'timezone' => 'UTC',
- 'fixedNowTime' => false
- },
- 'rank' => (int) 0,
- '[new]' => false,
- '[accessible]' => [
- '*' => true
- ],
- '[dirty]' => [],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'UserAssociation'
- },
- '[new]' => false,
- '[accessible]' => [
- '*' => true,
- '_joinData' => true
- ],
- '[dirty]' => [],
- '[original]' => [],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'Users'
- }
- ]
- ],
- '[virtual]' => [],
- '[errors]' => [],
- '[invalid]' => [],
- '[repository]' => 'Associations'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement