# |
Jul 23rd 2017, 17:35 |
newyorknick |
the only thing i see is `'action' => ['register', 'edit', 'view'],` |
# |
Jul 23rd 2017, 17:34 |
newyorknick |
I feel like thats a ridiculous question as a I see the register trait in the plugin but I can’t access it |
# |
Jul 23rd 2017, 17:32 |
newyorknick |
is there a standard register action by default? If so, whats the route? |
# |
Jul 23rd 2017, 15:33 |
chris-andre |
Check that you have followed https://book.cakephp.org/3.0/en/intro/conventions.html#model-and-database-conventions, and/or that `className` refers to the table class you intend to, and foreignKey is right. If you followed the conventions, it should be a pretty simple setup. If you don't, just a little more config to do. |
# |
Jul 23rd 2017, 15:30 |
chris-andre |
@tokam Users hasMany Tasks, Tasks belongsTo Users. So no, that relation is no problem. |
# |
Jul 23rd 2017, 12:06 |
iqbalchannar796 |
thanks chris-andre, not it is working fine for me, i greatful you, you have spent much time for solving me problem, so i am thankful for this, every time is need to add hidden flied for editing record |
# |
Jul 23rd 2017, 12:06 |
tokam |
is that a problem? |
# |
Jul 23rd 2017, 12:06 |
tokam |
I have mapped a belongsTo but on the other side a hasMany |
# |
Jul 23rd 2017, 12:06 |
tokam |
Hi, what might be a reason for cake php not loading a belongsTo association? |
# |
Jul 23rd 2017, 11:56 |
chris-andre |
I think a `$this->Form->input('users.0.id', ['type' => 'hidden'])` in your edit template will solve your problem. |
# |
Jul 23rd 2017, 11:54 |
chris-andre |
Here you see that it originally has an association with users: https://gist.github.com/anonymous/e04717f941d585ecdf53e67f5aa44059#file-gistfile1-txt-L71 This is the user you want to update. |
# |
Jul 23rd 2017, 11:54 |
chris-andre |
This is telling you that a new users is being created, but it fails because username is not unique and password is missing: https://gist.github.com/anonymous/e04717f941d585ecdf53e67f5aa44059#file-gistfile1-txt-L36 |
# |
Jul 23rd 2017, 11:52 |
chris-andre |
I'm a little short of time. Your issue is that when you patchEntity, your existing associated users are not updated. Instead your code is trying to create a new users with the data you provide in your edit-form. You need to somehow tell patchEntity that the posted users data is a existing user (in this case a user with id 11). |
# |
Jul 23rd 2017, 11:48 |
chris-andre |
What is that? What I ment. In your edit template, add a hidden field `$this->Form->input('users.0.id', ['type' => 'hidden'])`, then in your controllers edit(), `debug($person); die;` after patchEntity. |
# |
Jul 23rd 2017, 11:46 |
iqbalchannar796 |
https://gist.github.com/anonymous/e962a3f6406c64fc8b08b12f397bd117 |
# |
Jul 23rd 2017, 11:39 |
iqbalchannar796 |
fine, let me check |
# |
Jul 23rd 2017, 11:37 |
chris-andre |
Make sure the hidden field value is 11. |
# |
Jul 23rd 2017, 11:36 |
chris-andre |
Try to add users.0.id in your edit, then post and debug after patch |
# |
Jul 23rd 2017, 11:35 |
iqbalchannar796 |
fine sir, i am waiting.... |
# |
Jul 23rd 2017, 11:35 |
chris-andre |
https://gist.github.com/anonymous/e04717f941d585ecdf53e67f5aa44059#file-gistfile1-txt-L36 |
# |
Jul 23rd 2017, 11:35 |
iqbalchannar796 |
which line say this "Your $person after patchEntity says its a new user, thats wrong" |
# |
Jul 23rd 2017, 11:35 |
chris-andre |
Could you try to add a hidden field for `users.0.id` |
# |
Jul 23rd 2017, 11:31 |
chris-andre |
Let me have another look.. |
# |
Jul 23rd 2017, 11:31 |
chris-andre |
Sure, there is a solution. |
# |
Jul 23rd 2017, 11:31 |
chris-andre |
It looks right to me. But obviously something is wrong. Your $person after patchEntity says its a new user, thats wrong. But I can't figure out why. |
# |
Jul 23rd 2017, 11:29 |
iqbalchannar796 |
any way to fix this error |
# |
Jul 23rd 2017, 11:27 |
iqbalchannar796 |
https://gist.github.com/anonymous/327c85cbb410066cd45dd8ac399f620f |
# |
Jul 23rd 2017, 11:24 |
iqbalchannar796 |
https://gist.github.com/anonymous/c3540ff983ca7ef2d41f5487ca493968 |
# |
Jul 23rd 2017, 11:23 |
iqbalchannar796 |
let me add |
# |
Jul 23rd 2017, 11:22 |
chris-andre |
Gist your edit template. |
# |
Jul 23rd 2017, 11:21 |
chris-andre |
Does persons hasMany users? |
# |
Jul 23rd 2017, 11:21 |
chris-andre |
The other problem is that your patched entity don't associate with the user you have contained in $person. |
# |
Jul 23rd 2017, 11:20 |
iqbalchannar796 |
and how to change this `isNew => true`, |
# |
Jul 23rd 2017, 11:20 |
chris-andre |
persons hasMany users? |
# |
Jul 23rd 2017, 11:19 |
iqbalchannar796 |
how to fix it chris-andre |
# |
Jul 23rd 2017, 11:19 |
iqbalchannar796 |
https://gist.github.com/anonymous/d5100e124b1ca7daac4c20457b2c16da |
# |
Jul 23rd 2017, 11:19 |
iqbalchannar796 |
$person->errors() |
# |
Jul 23rd 2017, 11:18 |
chris-andre |
For a reason your associated users is marked as new, `isNew => true`, that is why |
# |
Jul 23rd 2017, 11:16 |
iqbalchannar796 |
https://gist.github.com/anonymous/e04717f941d585ecdf53e67f5aa44059 |
# |
Jul 23rd 2017, 11:12 |
iqbalchannar796 |
sure |
# |
Jul 23rd 2017, 11:12 |
chris-andre |
can you `debug($person); die;` after patchEntity, and gist output? |