1
很抱歉,如果我的问题是含糊不清我试图保持尽可能简单,我使用CakePHP的下列控制器:当我使用其他表格数据在cakephp中显示时,如何保存表格中的数据?
var $uses = array('Client','Ticket','Userseequeue','Queue','Task','User');
var $useTable = false;
function index() {
$clientsResult = $this->Client->find('all');
$userSeeQueuesResult = $this->Userseequeue->find('all', array('conditions' => array('Userseequeue.user_id' => '1')));
$ticketsResult = $this->Ticket->find('all');
$queuesResult = $this->Queue->find('all');
$tasksResult = $this->Task->find('all', array('group' => array('Task.ticket_id','Task.queue_id')));
$usersResult = $this->User->find('all');
$this->set(compact('tickets','userSeeQueues','clients','queuesResult','tasksResult','users','ticketUsers','ticketQueues'));
if (!empty($this->data)) {
$this->Ticket->create();
$this->Ticketsinqueue->insertData($this->data);
if ($this->Ticket->save($this->data) && $this->Ticketsinqueue->save($this->data)) {
$this->Session->setFlash(__('The ticket has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The ticket could not be saved. Please, try again.', true));
}
}
}
我使用这些表在单个视图中显示的信息的摘要。
我需要在该视图屏幕上添加一个表单以添加附加票证。我在做什么错误或缺少创建此表格并将其保存到表格中?
这是我的看法,我试图创建形式,在情况下,它可能会帮助:
<div class="Summary index">
<h2><?php __('Summary');?></h2>
<?php echo $this->Form->create('Ticket');?>
<fieldset>
<legend><?php __('Add Ticket'); ?></legend>
<?php
echo $this->Form->input('Ticket.name');
echo $this->Form->input('Ticket.user_id');
echo $this->Form->input('Ticket.queue_id');
?>
<?php echo $this->Form->end(__('Submit', true));?>
</fieldset>
...
这将创建形式,但它不会填充下拉列表,从它正确的关系的表,因为它会在cakephp创建的正常添加视图中。它目前用我在这个控制器中使用的所有表格填充下拉列表。
如果有人能帮助我或帮助我走向正确的方向,我将不胜感激。