0
我想在一個選項卡中使用CakePHP中的2個表單。CakePHP表單不發佈數據
我想在視圖中使用操作'financial_day_begin'。
控制器有兩個函數'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文件之外是否有一些地方需要定義應該調用的動作?
對這個問題的任何幫助是非常感謝。
基本上,我想說,在我看來,有2種形式,調用同樣的動作。從應用程序,只有當我改變我的選擇在第二種形式,行動(函數financial_day_begin)被調用。以第一種形式更改選擇不會調用該操作。我在這裏做錯了什麼?我也嘗試過使用不同的函數名稱,但第一種形式的動作並沒有被調用。 – user2358060 2013-05-14 06:54:19