我想在一个选项卡中使用 CakePHP 中的 2 个表单。
我正在尝试在视图中使用操作“financial_day_begin”。
控制器有 2 个函数“financial_day”和“financial_bill_day”,我在“financial_day_begin”中调用了这两个函数。
以下是视图代码,financial_day_begin.ctp:
<div class="panel">
<h2><?php echo sprintf(__("End of Business %s", true), $financial['Financial']['_end_of_business_date']); ?></h2>
<div class="panel-content">
<?php echo $this->element('reports/tabs'); ?>
<div id="search" class="form">
<?php
echo $this->Form->create('Finbill', array('url' => array(
'controller' => 'reports',
'action' => 'financial_day_begin'
)));
echo $this->Form->input('end_of_bill_date', array(
'label' => __("Select Cycle", true),
'options' => $finbillList
));
echo $this->Form->end();
?>
</div>
<?php
$labels = array(
'billed_in_cycle'
);
echo $this->Html->tag('h3', __("Billed", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($finbill['Finbill'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
?>
<div id="search" class="form">
<?php
echo $this->Form->create('Financial', array('url' => array(
'controller' => 'reports',
'action' => 'financial_day_begin'
)));
echo $this->Form->input('end_of_business_date', array(
'label' => __("Select Day", true),
'options' => $financialList
));
echo $this->Form->end();
?>
</div>
<?php
$labels = array(
'billed_adjustments' => 'Adjustments'
);
echo $this->Html->tag('h3', __("Adjustments", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
$labels = array(
'payments',
'payment_reversals',
'payments_net' => 'Net Payments'
);
echo $this->Html->tag('h3', __("Payments", true));
echo $this->DataTable->create(array('class' => 'vertical'));
foreach($labels as $key => $label) {
if(is_numeric($key)) {
$key = $label;
$label = Inflector::humanize($label);
}
echo $this->DataTable->createRow();
echo $this->DataTable->createHeader(__($label, true));
echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value'));
echo $this->DataTable->endRow();
}
echo $this->DataTable->end();
?>
</div>
</div>
<?php
$this->Html->script("reports/financial_day", array('inline' => false));
?>
这是我的控制器,reports_controller.php:
<?php
class ReportsController extends AppController {
var $name = 'Reports';
var $uses = array(
'Subscriber',
'Financial',
'Finbill',
'Trend'
);
var $presetVars = array(
array(
'field' => 'posted',
'type' => 'value'
),
array(
'field' => 'end_of_business_date',
'type' => 'value'
),
array(
'field' => 'end_of_bill_date',
'type' => 'value'
),
array(
'field' => 'start_id',
'type' => 'value'
),
array(
'field' => 'end_id',
'type' => 'value'
),
array(
'field' => 'month_year',
'type' => 'value'
)
);
function index() {
$subscriber = $this->Subscriber->find('first', array(
'contain' => false,
'order' => array('posted' => 'desc')
));
$this->set(compact('subscriber'));
}
function financial_bill_day() {
$this->Prg->commonProcess('Finbill');
$searchConditions = $this->Finbill->parseCriteria($this->passedArgs);
$finbill = $this->Finbill->find('first', array(
'conditions' => $searchConditions,
'contain' => false,
'order' => array('end_of_bill_date' => 'desc')
));
$finbillList = $this->Finbill->find('list', array(
'contain' => false,
'fields' => array(
'end_of_bill_date'
),
'order' => array('end_of_bill_date' => 'desc')
));
$this->set(compact('finbill', 'finbillList'));
}
function financial_day() {
$this->Prg->commonProcess('Financial');
$searchConditions = $this->Financial->parseCriteria($this->passedArgs);
$financial = $this->Financial->find('first', array(
'conditions' => $searchConditions,
'contain' => false,
'order' => array('end_of_business_date' => 'desc')
));
$financialList = $this->Financial->find('list', array(
'contain' => false,
'fields' => array(
'end_of_business_date',
'_end_of_business_date'
),
'order' => array('end_of_business_date' => 'desc')
));
$this->set(compact('financial','financialList'));
}
function financial_day_begin() {
$this->financial_day();
$this->financial_bill_day();
$this->set(compact('finbill','finbillList','financial','financialList'));
}
}
?>
问题是,当我尝试从选择框中的下拉列表中选择输入值时,没有发布任何内容(根据浏览器中的地址栏)。我猜这就是为什么也不调用新值的原因。
在 ctp 文件之外是否有我们需要定义应该调用的操作的地方?
非常感谢您对此问题的任何帮助。