Advertisement
Guest User

asd

a guest
Sep 27th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. debug($this->request->data):
  2. [
  3. 'users' => [
  4. (int) 0 => [
  5. '_joinData' => [
  6. 'rank' => '0'
  7. ]
  8. ],
  9. (int) 1 => [
  10. '_joinData' => [
  11. 'rank' => '0'
  12. ]
  13. ]
  14. ]
  15. ]
  16. VIEW:
  17. <?= $this->Form->create($association) ?>
  18. <?php $i = 0; ?>
  19. <?php foreach ($association->users as $user) : ?>
  20. <tr>
  21. <td><?= $user->username ?></td>
  22. <td><?= $user->_joinData->created; ?></td>
  23. <td>
  24. <?= $this->Form->select('users.' . $i . '._joinData.rank', ['options' => ['0' => 'User', '1' => 'Author']]); ?></td>
  25. <?php $i = $i + 1; ?>
  26.  
  27. </tr>
  28. <?php endforeach ?>
  29. CONTROLLER:
  30. $association = $this->Associations->get($id, [
  31. 'contain' => ['Users']
  32. ]);
  33.  
  34. if ($this->request->is(['patch', 'post', 'put'])) {
  35. $association = $this->Associations->patchEntity($association, $this->request->data, ['associated' => ['Users' => ['validate' => false]]]);
  36. debug($this->request->data);
  37. debug($association);
  38. die();
  39. if ($this->Associations->save($association, ['associated' => ['Users' => ['validate' => false]]])) {
  40. $this->Flash->success(__('Your changes have been saved.'));
  41. return $this->redirect(['action' => 'index']);
  42. } else {
  43. $this->Flash->error(__('Your changes could not be saved. Please, try again.'));
  44. }
  45. }
  46.  
  47. $this->set('association', $association);
  48. $this->set('_serialize', ['association']);
  49.  
  50. debug:
  51. object(App\Model\Entity\Association) {
  52.  
  53. 'id' => (int) 1,
  54. 'name' => '123',
  55. 'users' => [
  56. (int) 0 => object(App\Model\Entity\User) {
  57.  
  58. '_joinData' => object(App\Model\Entity\UserAssociation) {
  59.  
  60. 'rank' => (int) 0,
  61. '[new]' => true,
  62. '[accessible]' => [
  63. '*' => true
  64. ],
  65. '[dirty]' => [
  66. 'rank' => true
  67. ],
  68. '[original]' => [],
  69. '[virtual]' => [],
  70. '[errors]' => [],
  71. '[invalid]' => [],
  72. '[repository]' => 'UserAssociation'
  73.  
  74. },
  75. '[new]' => true,
  76. '[accessible]' => [
  77. '*' => true,
  78. '_joinData' => true
  79. ],
  80. '[dirty]' => [
  81. '_joinData' => true
  82. ],
  83. '[original]' => [
  84. '_joinData' => [
  85. 'rank' => '0'
  86. ]
  87. ],
  88. '[virtual]' => [],
  89. '[errors]' => [],
  90. '[invalid]' => [],
  91. '[repository]' => 'Users'
  92.  
  93. },
  94. (int) 1 => object(App\Model\Entity\User) {
  95.  
  96. '_joinData' => object(App\Model\Entity\UserAssociation) {
  97.  
  98. 'rank' => (int) 0,
  99. '[new]' => true,
  100. '[accessible]' => [
  101. '*' => true
  102. ],
  103. '[dirty]' => [
  104. 'rank' => true
  105. ],
  106. '[original]' => [],
  107. '[virtual]' => [],
  108. '[errors]' => [],
  109. '[invalid]' => [],
  110. '[repository]' => 'UserAssociation'
  111.  
  112. },
  113. '[new]' => true,
  114. '[accessible]' => [
  115. '*' => true,
  116. '_joinData' => true
  117. ],
  118. '[dirty]' => [
  119. '_joinData' => true
  120. ],
  121. '[original]' => [
  122. '_joinData' => [
  123. 'rank' => '0'
  124. ]
  125. ],
  126. '[virtual]' => [],
  127. '[errors]' => [],
  128. '[invalid]' => [],
  129. '[repository]' => 'Users'
  130.  
  131. }
  132. ],
  133. '[new]' => false,
  134. '[accessible]' => [
  135. '*' => true
  136. ],
  137. '[dirty]' => [
  138. 'users' => true
  139. ],
  140. '[original]' => [
  141. 'users' => [
  142. (int) 0 => object(App\Model\Entity\User) {
  143.  
  144. 'id' => (int) 2,
  145. 'username' => 'name',
  146. 'password' => '',
  147. 'email' => '',
  148. 'img' => 'users/blank-profile-picture.png',
  149. 'created' => object(Cake\I18n\FrozenTime) {
  150.  
  151. 'time' => '2016-02-04T00:00:00+00:00',
  152. 'timezone' => 'UTC',
  153. 'fixedNowTime' => false
  154.  
  155. },
  156. 'modified' => object(Cake\I18n\FrozenTime) {
  157.  
  158. 'time' => '2016-09-27T14:17:20+00:00',
  159. 'timezone' => 'UTC',
  160. 'fixedNowTime' => false
  161.  
  162. },
  163. 'role' => 'admin',
  164. 'api_key' => '',
  165. 'api_key_plain' => '',
  166. 'verified' => true,
  167. 'banned' => false,
  168. 'last_login' => object(Cake\I18n\FrozenTime) {
  169.  
  170. 'time' => '2016-09-27T14:17:20+00:00',
  171. 'timezone' => 'UTC',
  172. 'fixedNowTime' => false
  173.  
  174. },
  175. '_joinData' => object(App\Model\Entity\UserAssociation) {
  176.  
  177. 'user_id' => (int) 2,
  178. 'id' => (int) 0,
  179. 'association_id' => (int) 1,
  180. 'created' => object(Cake\I18n\FrozenTime) {
  181.  
  182. 'time' => '2016-09-15T06:00:00+00:00',
  183. 'timezone' => 'UTC',
  184. 'fixedNowTime' => false
  185.  
  186. },
  187. 'rank' => (int) 0,
  188. '[new]' => false,
  189. '[accessible]' => [
  190. '*' => true
  191. ],
  192. '[dirty]' => [],
  193. '[original]' => [],
  194. '[virtual]' => [],
  195. '[errors]' => [],
  196. '[invalid]' => [],
  197. '[repository]' => 'UserAssociation'
  198.  
  199. },
  200. '[new]' => false,
  201. '[accessible]' => [
  202. '*' => true,
  203. '_joinData' => true
  204. ],
  205. '[dirty]' => [],
  206. '[original]' => [],
  207. '[virtual]' => [],
  208. '[errors]' => [],
  209. '[invalid]' => [],
  210. '[repository]' => 'Users'
  211.  
  212. },
  213. (int) 1 => object(App\Model\Entity\User) {
  214.  
  215. 'id' => (int) 13,
  216. 'username' => 'random username',
  217. 'password' => '',
  218. 'email' => '',
  219. 'img' => '',
  220. 'created' => object(Cake\I18n\FrozenTime) {
  221.  
  222. 'time' => '2016-05-06T10:39:02+00:00',
  223. 'timezone' => 'UTC',
  224. 'fixedNowTime' => false
  225.  
  226. },
  227. 'modified' => object(Cake\I18n\FrozenTime) {
  228.  
  229. 'time' => '2016-05-06T10:46:58+00:00',
  230. 'timezone' => 'UTC',
  231. 'fixedNowTime' => false
  232.  
  233. },
  234. 'role' => 'user',
  235. 'api_key' => '',
  236. 'api_key_plain' => '',
  237. 'verified' => true,
  238. 'banned' => false,
  239. 'last_login' => null,
  240. '_joinData' => object(App\Model\Entity\UserAssociation) {
  241.  
  242. 'user_id' => (int) 13,
  243. 'id' => (int) 1,
  244. 'association_id' => (int) 1,
  245. 'created' => object(Cake\I18n\FrozenTime) {
  246.  
  247. 'time' => '2016-09-12T06:00:00+00:00',
  248. 'timezone' => 'UTC',
  249. 'fixedNowTime' => false
  250.  
  251. },
  252. 'rank' => (int) 0,
  253. '[new]' => false,
  254. '[accessible]' => [
  255. '*' => true
  256. ],
  257. '[dirty]' => [],
  258. '[original]' => [],
  259. '[virtual]' => [],
  260. '[errors]' => [],
  261. '[invalid]' => [],
  262. '[repository]' => 'UserAssociation'
  263.  
  264. },
  265. '[new]' => false,
  266. '[accessible]' => [
  267. '*' => true,
  268. '_joinData' => true
  269. ],
  270. '[dirty]' => [],
  271. '[original]' => [],
  272. '[virtual]' => [],
  273. '[errors]' => [],
  274. '[invalid]' => [],
  275. '[repository]' => 'Users'
  276.  
  277. }
  278. ]
  279. ],
  280. '[virtual]' => [],
  281. '[errors]' => [],
  282. '[invalid]' => [],
  283. '[repository]' => 'Associations'
  284.  
  285. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement