1
我嘗試使用Symfony 1.4 froms傳遞一些值。Symfony 1.4從select中傳遞值而不刷新頁面
我試圖做的是將值從SELECT傳遞給$變量而不刷新頁面。
CreateForm.php
$this->setWidget('cycle', new sfWidgetFormChoice(array(
'label' => __('Cycle'),
'choices' => $this->getCycles()
), array(
'class' => 'inputText',
)));
$this->setValidator('cycle', new sfValidatorChoice(array(
'required' => true,
'choices' => array_keys($this->getCycles())
), array(
)));
$this->setWidget('startCycle', new sfWidgetFormChoice(array(
'label' => __('Start cycle'),
'choices' => ''
), array(
'class' => 'inputTextshort',
)));
$this->setValidator('startCycle', new sfValidatorChoice(array(
'required' => true,
'choices' => ''
), array(
)));
$this->setWidget('endCycle', new sfWidgetFormChoice(array(
'label' => __('End cycle'),
'choices' => ''
), array(
'class' => 'inputTextshort',
)));
$this->setValidator('endCycle', new sfValidatorChoice(array(
'required' => true,
'choices' => ''
), array(
)));
而且在CreateForm.php一些功能:
public function getCycles()
{
return array(
'DAY' => 'DAY',
'WEEK' => 'WEEK',
'MONTH' => 'MONTH',
'YEAR' => 'YEAR'
);
}
public function getCyclesValues() {
$arrCyclesValues = array(
'DAY' => array(
'start' => range(0,23),
'end' => range(0,23),
),
'WEEK' => array(
'start' => range(1,7),
'end' => range(1,7),
),
'MONTH' => array(
'start' => range(0,13),
'end' => range(0,13), 'can_be_empty' => true,
),
'YEAR' => array(
'start' => range(1,365),
'end' => range(1,365),
),
);
$start_day_cycyle = $arrCyclesValues['DAY']['start'];
$stop_day_cycyle = $arrCyclesValues['DAY']['stop'];
$start_week_cycyle = $arrCyclesValues['WEEK']['start'];
$stop_week_cycyle = $arrCyclesValues['WEEK']['stop'];
$start_month_cycyle = $arrCyclesValues['MONTH']['start'];
$stop_month_cycyle = $arrCyclesValues['MONTH']['stop'];
$start_year_cycyle = $arrCyclesValues['YEAR']['start'];
$stop_year_cycyle = $arrCyclesValues['YEAR']['stop'];
}
public function getCycle() {
}
基本上,查看給我可能要檢查的四個週期之一:
http://i.imgur.com/emDqOv1.png
當我檢查4個值中的一個時,我需要在不刷新頁面的情況下捕獲它,並將它放在$ variable變量中以獲取CreateForm.php腳本的getCycle()方法。
任何幫助將不勝感激,感謝..
任何人???? : - | – Tomas