【发布时间】:2013-09-23 05:14:43
【问题描述】:
情况是这样的。我们需要能够创建报价。报价包含组件:研究、Pesel 和预约、抄送和注册和设置费用。一个报价可能有也可能没有,但最多只能有 1 个。
我们在一个视图上有一系列表单,我们将这些表单划分为选项卡,以便一次只能查看一个。选项卡和第一个表单的代码在这里:
<script>
$(function()
{`
$( "#tabs" ).tabs();
});
$(function() {
$( "#accordion" ).accordion({
active: false,
collapsible: true,
heightStyle: "content"
});
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Quote Info</a></li>
<li><a href="#tabs-2">Research</a></li>
<li><a href="#tabs-3">CC and Registration</a></li>
<li><a href="#tabs-4">PESEL and appointment</a></li>
<li><a href="#tabs-5">Other Fees</a></li>
</ul>
<div id="tabs-1">
<?php echo $this->Form->create('Quote'); ?>
<p>
<h3>Quote Information</h3>
<p>
<fieldset>
<div id="hide"><?php echo $this->Form->input('date', array('dateFormat' => 'DMY'));?></div>
<?php
echo $this->Form->input('description');
echo $this->Form->input('quote_accepted');
echo $this->Form->input('research_accepted');
echo $this->Form->input('cc_accepted');
echo $this->Form->input('pesel_accepted');
echo $this->Form->input('setfees_accepted');
echo $this->Form->input('total', array('value' => '0'));
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
第一种形式可以正常工作。一个不起作用的是这里:
<div id="tabs-5">
<?php echo $this->Form->create('Quote'); ?>
<h3><?php echo __('Other Fees'); ?></h3>
<table>
<tbody>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Initial Price</th>
<th>Client Price</th>
<th>Total</th>
</tr>
<tr>
<td><h5>Children under 18</h5></td>
<td> <?php echo $this->Form->input('Setfee.children_quantity', array('label' => ''));?> </td>
<td>$900</td>
<td><input type="text"> </td>
<td> <?php echo $this->Form->input('Setfee.children_total', array('label' => ''));?> </td>
</tr>
<tr>
<td><h5>Relatives of Confirmed Citizens</h5></td>
<td> <?php echo $this->Form->input('Setfee.relatives_quantity', array('label' => ''));?> </td>
<td>$900</td>
<td><input type="text"> </td>
<td> <?php echo $this->Form->input('Setfee.relatives_total', array('label' => ''));?> </td>
</tr>
<tr>
<td><h5>Registration of One Birth or Marriage Certificate</h5></td>
<td> <?php echo $this->Form->input('Setfee.reg_birth_marriage_quantity', array('label' => ''));?> </td>
<td>$50</td>
<td><input type="text"> </td>
<td> <?php echo $this->Form->input('Setfee.reg_birth_marriage_total', array('label' => ''));?> </td>
</tr>
<tr>
<td><h5>Registration of Birth and Marriage Certificate Altogether</h5></td>
<td> <?php echo $this->Form->input('Setfee.reg_birth_marriage_together_quantity', array('label' => ''));?> </td>
<td>$50</td>
<td><input type="text"> </td>
<td> <?php echo $this->Form->input('Setfee.reg_birth_marriage_together_total', array('label' => ''));?> </td>
</tr>
<tr>
<td><h5>Standard Fees</h5></td>
<td></td>
<td></td>
<td></td>
<td> <?php echo $this->Form->input('Setfee.standard_fee_total', array('label' => ''));?> </td>
</tr>
<tr>
<td> <h5><?php echo $this->Form->input('Setfee.set_fees_total');?></h5></td>
<td></td>
<td></td>
<td></td>
<div id='hide' ><?php echo $this->Form->input('Setfee.quote_id');?></div>
<td><?php echo $this->Form->end(__('Submit')); ?></td>
</tr>
</tbody>
</table>
</div>
保存的控制器在这里:
public function makeQuote()
{
$this->loadModel('Applicant');
$this->LoadModel('ApplicantQuote');
$this->LoadModel('Setfee');
//retrieves the applicants chosen from the view_quotes page
$args = $this->params['url'];
$applicants = $this->Applicant->find('all', array('conditions' => array('id' => $args),
'order' => 'first_name ASC', 'recursive' => -1));
$this->set(compact('applicants'));
if ($this->request->is('post'))
{
$this->Quote->create();
if($this->Quote->saveall($this->request->data))
{
$this->Session->setflash(__('quote saved'));
}
}
基本上,我们需要能够彼此独立地保存表单。至于型号。 Quotes 有一个固定的费用,抄送和注册,pesel 和研究,每一个都属于报价。
我们是 cakephp 的新手,我们已经走到了尽头。请帮忙。
【问题讨论】:
-
什么不起作用?你遇到了什么错误?您确实意识到,即使您在一个页面上显示了多个表单,您也只能在给定的请求中提交一个?
-
如果我们尝试提交除第一个以外的任何表单,则无法保存。它不显示错误,页面刷新并且没有任何反应。