0

我有一个使用视图文件调用的元素。该元素是一个添加视图,即 add.ctp,我现在面临的挑战是该元素没有将表单输入插入到表中(it_query_responses)。

这是我在视图中调用我的元素的方式 -

<?php echo $this->Element('ItQueryResponses/add'); ?>

这是元素的代码

<?php echo $this->Form->create('ItQueryResponse'); ?>
<legend><?php echo __('Add It Query Response'); ?></legend>
<?php
echo $this->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');
?>
<?php echo $this->Form->end(__('Submit')); ?>

这是ItQueryResponsesController中的添加功能

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'));
}
4

0 回答 0