从视图向控制器发送信息


Send info from View to Controller

我第一次在cakephp为我正在开发的一个项目工作。在视图中,我有一个数组,我希望能够在其中使用控制器函数。

存放信息的数组就是这个

 $linkedinInfo

然后在视图中,我使用表单将数组从视图发送到控制器

       $this->Form->create('LinkedinData', array('controller'=>'Users','type' => 'post', 'action' => 'add'));
       $this->Form->input('User', $linkedinInfo);
       $this->Form->end('submit');

添加是添加是一个功能在用户控制器,不是由我开发的。函数

       public function add() {
        if ($this->request->is('post')) {
          $this->User->create();
          if ($this->User->save($this->request->data)) {
            $this->Session->setFlash(__('The user has been saved'));
            $this->redirect(array('action' => 'index'));
           } else {
          $this->Session->setFlash(__('The user could not be saved. Please, try   again.'));
         }}

我得到错误"数组到字符串转换"在这个,我不是很熟悉在CakePHP工作,但我不明白为什么我得到这个,因为cookbook使用一切像我一样http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html


编辑:LinkedinInfo是我通过Linkedin API获得的数组,然后我对它进行后编辑。下面是推荐部分的结构示例

[linkedin_recomendations] => Array
    (
        [0] => Array
            (
                [name] => test1
                [relationship] => education
                [text] => Hello world
            )
        [1] => Array
            (
                [name] => test2
                [relationship] => colleague
                [text] => Derp
            )
    )

我要做的是将此信息发送到UsersController,它将在Mongodb数据库中创建一个用户

您试图提交的数据格式不正确。

请检查本手册以确保您的数据格式正确。

http://book.cakephp.org/2.0/en/models/saving-your-data.html