Note that there are some explanatory texts on larger screens.

plurals
  1. POSend info from View to Controller
    primarykey
    data
    text
    <p>I am working for the first time in cakephp for a project I am developing. In a view I have an array that I want to be able to use a controller function in it.</p> <p>The array I have the info in is this one </p> <pre><code> $linkedinInfo </code></pre> <p>And then in the view I was using a form to send the array from the view to the controller</p> <pre><code> $this-&gt;Form-&gt;create('LinkedinData', array('controller'=&gt;'Users','type' =&gt; 'post', 'action' =&gt; 'add')); $this-&gt;Form-&gt;input('User', $linkedinInfo); $this-&gt;Form-&gt;end('submit'); </code></pre> <p>Add being add being a function in the Users controller that was not developed by me. The function being </p> <pre><code> public function add() { if ($this-&gt;request-&gt;is('post')) { $this-&gt;User-&gt;create(); if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data)) { $this-&gt;Session-&gt;setFlash(__('The user has been saved')); $this-&gt;redirect(array('action' =&gt; 'index')); } else { $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.')); }} </code></pre> <p>I am getting the error "Array to string conversion" in this, I am not very familiar with working in CakePHP but I don't see why I get this since the Cookboek uses everything like me <a href="http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html" rel="nofollow">http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html</a></p> <hr> <p>Edit: LinkedinInfo is an array that I obtain through the Linkedin API and then I posteriorly edit it. Here a sample of the structure just for the recomendations part</p> <pre><code>[linkedin_recomendations] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; test1 [relationship] =&gt; education [text] =&gt; Hello world ) [1] =&gt; Array ( [name] =&gt; test2 [relationship] =&gt; colleague [text] =&gt; Derp ) ) </code></pre> <p>What I am trying to do is to send this information to the UsersController where it will create an user with it in a Mongodb database</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload