Передача значений формы из элемента в таблицу в cakephp
У меня есть система ИТ-запросов, где пользователи добавляют свои запросы. Когда я просматриваю запрос, я должен иметь возможность добавить ответ на запрос. Ответ должен быть добавлен в таблицу с именем it_query_responses, а имя модели - ItQueryResponse.
Через элемент я включаю ответ add в view.ctp для ИТ-запросов. Проблема, с которой я столкнулся сейчас, заключается в том, что элемент не сохраняет ответ в таблицу it_query_responses.
Вот моя функция добавления для контроллера ответа
public function add() {
if ($this->request->is('post')) {
$this->ItQueryResponse->create();
if ($this->ItQueryResponse->save($this->request->data)) {
$this->Session->setFlash(__('The it query response has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The it query response could not be saved. Please, try again.'));
}
}
$itQueries = $this->ItQueryResponse->ItQuery->find('list');
$hrEmployees = $this->ItQueryResponse->HrEmployee->find('list');
$itQueryStatuses = $this->ItQueryResponse->ItQueryStatus->find('list');
$this->set(compact('itQueries', 'hrEmployees', 'itQueryStatuses'));
}
и вот как я называю свой элемент после закрытия div в view.ctp
element('ItQueryResponses/add'); ?>
вот код для моего элемента
Form->create('ItQueryResponse'); ?>
Form->input('it_query_id');
echo $this->Form->input('hr_employee_id');
echo $this->Form->input('response');
echo $this->Form->input('it_query_status_id');
?>
Form->end(__('Submit')); ?>
Заранее спасибо.