Tuesday, August 19, 2014

Re: CakePHP 3 - patchEntity to one model from another

Do you have a products table?

It looks like the array your are passing looks like a the name of an association, so Cake is trying to create entities for those associations. Maybe it is a deposit association?

On Tuesday, August 19, 2014 2:22:26 PM UTC+2, rachel...@thecarfinancecompany.co.uk wrote:
Hi,

I've got a form which updates several tables. The form is for a model (Proposals) that has hasMany relationships to the other tables. The data comes back from the form as the following array:

Array  (      [proposals] => Array          (              [id] => 1              [marketing_source_id] => 16          )        [financials] => Array          (              [asset_price] => 15000              [deposit] => 15              [product] => 11          )        [applicants] => Array          (              [customer_type_id] => 8          )        [assets] => Array          (              [asset_type_id] => 1          )    )

I have the following lines of code, to do the patchEntity before the save:

$proposal = $this->Proposals->patchEntity($proposal, $this->request->data['proposals']);
$financial = $this->Financials->patchEntity($financial, $this->request->data['financials']);

The $proposal one works fine, as I'm in the Proposal model. The $financial one gives the errors:

Warning (4096): Argument 1 passed to Cake\ORM\Marshaller::one() must be of the type array, string given, called in /var/www/html/dmv3/vendor/cakephp/cakephp/src/ORM/Marshaller.php on line 149 and defined [CORE/src/ORM/Marshaller.php, line 96]
Warning (2): Invalid argument supplied for foreach() [CORE/src/ORM/Marshaller.php, line 110]
What am I doing wrong? $financial is an entity; if I pass it as an array, it tells me it must be of type entity.

thanks!

******* CONFIDENTIALITY NOTICE AND LEGAL LIABILITY WAIVER *******

The content of this email and any attachments are CONFIDENTIAL and may contain privileged information. If you are not the addressee it may be UNLAWFUL for you to read, copy, distribute or disclose the information contained herein. This email and any attachments may not reflect the opinions of the originating company or any party it is representing. Telephone calls may be recorded for training and quality monitoring purposes.

The Car Finance Company (2007) Ltd Registered Address is 85 Kingston Crescent, Portsmouth, PO2 8AA and is authorised and regulated by the Financial Conduct Authority, CCL number 600168. 

The Car Finance Company (Trade Sales) Ltd is a wholly owned subsidiary of The Car Finance Company (2007) Ltd. Registered Address is 85 Kingston Crescent, Portsmouth, PO2 8AA and is authorised and regulated by the Financial Conduct Authority, CCL number 663690.

--
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: