Monday, June 23, 2014

Re: what is request array to save multiple records in cakephp3 ?

saveAssociated() method is not exist in cakephp 3.

On Tuesday, 24 June 2014 11:49:07 UTC+5:30, A.K. Mahana wrote:


On Tuesday, June 24, 2014 10:21:29 AM UTC+5:30, Archana Goyal wrote:
Hi Mahana,

I have saperate table and entity of links and hasmany association defined in LinksTable.php.
In links table primary key and foreign key saved but other fields not saved.

On Tuesday, 24 June 2014 10:04:20 UTC+5:30, A.K. Mahana wrote:


On Monday, June 23, 2014 12:11:56 PM UTC+5:30, Archana Goyal wrote:
Hi,
I am building cakephp 3 application. I want to save associated multiple records.
my $this->request->data is
Array  (         [name] => archana
[phone] => 234234
  [links] => Array ( [0] => Array ( ['link'] => www.google.com ['user_id'] => 1 ) ) )

In my associate table data saved like

id | link | user_id | resume_id
1 | | | 1

and I want like this
id | link               | user_id | resume_id
1 | www.google.com | 1 | 1



Hi,

I think this is a problem of association as the same model could not have many records foa a field without association, So you may try creating a separate model called Link and the main model relate that with hasMany relation. Otherwise you can use json to store data and apply logic to show data on view.



have u used saveAssociated() method ?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: