我有一个使用视图文件调用的元素。元素是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中的add函数
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'));
}