ошибка на множественном выборе - PullRequest
1 голос
/ 03 апреля 2012

Я получаю следующую ошибку при попытке сохранить.

SQL Query: INSERT INTO `table`.`users` (`username`, `password`, `group_id`, `applications`, `modified`, `created`) VALUES ('asdasd', '23ad37a839e26fc46a1f6640861a47305aea5d46', 3, Array, '2012-04-03 02:12:19', '2012-04-03 02:12:19')

вот код для множественного выбора

echo $this->Form->input('User.applications',array('options'=>$options,'multiple'=>'multiple'));

и вызывается метод add, который:

if ($this->request->is('post')) {
                                //debug($this->request);exit;   
                                $this->User->create();
                                if ($this->User->saveAll($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.'));
                                }
                            }
                            $groups = $this->User->Group->find('list');
                            $this->set(compact('groups'));

спасибо!

1 Ответ

0 голосов
/ 03 апреля 2012

решил, используя это

public function add() {
                            if ($this->request->is('post')) {

                                if(count($this->request->data['User']['applications'])){
                                    $this->request->data['User']['applications'] = implode(",", $this->request->data['User']['applications']);
                                }
                ....
...