情况是这样的。我们需要能够创建报价。报价包含组件:研究、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'));
}
}
基本上我们需要能够彼此独立地保存表单。至于型号。报价具有固定费用之一,抄送和注册,pesel 和研究,每一个都属于报价。
我们是 cakephp 的新手,我们已经走到了尽头。请帮忙。