0
我想有一個下拉列表和一個提交按鈕,當按鈕按下時,我想獲取所選項目的文本並將其存儲到數據庫中。我認爲下拉代碼是:下拉列表中提交yii
<?php
$form=$this->beginWidget('CActiveForm', array(
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true
),
)); ?>
<?php echo $form->labelEx($model,'actTopic'); ?>
<?php echo $form->error($model,'actTopic'); ?>
<?php
echo CHtml::dropDownList('actTopic', $category,$list,
array('empty' => '... '));
?>
它生成一個下拉列表罰款。 但我不知道如何在我的動作函數中獲取選定的項目。 的動作功能是:
public function actiongivePoint()
{
$model=new GivePointForm;
if(isset($_POST['GivePointForm'])){
$model->attributes=$_POST['GivePointForm'];
if($model->validate()){
$actTopic=($model->actTopic);
$actPoint=($model->actPoint);
$actId=($model->actId);
$stCode = (int) $_GET['stCode'];
$connection=Yii::app()->db;
$connection->active=TRUE;
$actIdReader =Yii::app()->db->createCommand()
->select ('actID')
->from('refrencepoint')
->where("actTopic=:actTopic")
->queryScalar(array(':actTopic'=>$actTopic));
$search =Yii::app()->db->createCommand()
->select ('count(*)')
->from('point')
->where(array('and', 'actId=:actID', 'stCode=:stCode') )
->queryScalar(array(':actId'=>$actId,':stCode'=>$stCode));
if($search !=0){
$month=CDateFormatter::formatMonth(now());
$year=CDateFormatter::formatMonth(now());
$command =$command->update('point', array(
'year'=>$year,'month'=>$month,
'pcounter'=>new CDbExpression('pcounter + 1'),),
(array('and','actId'=>$actId, 'stCode'=>$stCode))) ;
Yii::app()->user->setFlash('point','....');
}
else{
$month=CDateFormatter::formatMonth(now());
$year=CDateFormatter::formatMonth(now());
$command->insert('point', array('actId'=>$actId,
'stCode'=>$stCode,'year'=>$year,'month'=>$month,
'pcounter'=>new CDbExpression('pcounter + 1')));
Yii::app()->user->setFlash('point','....');
}
}
}
$this->render('givePoint',array('model'=>$model));
}
我應該說我不使用活動記錄。
上面的代碼看起來好像一切正常,但當我按提交按鈕什麼都沒有發生,沒有數據庫的變化,甚至沒有錯誤,只是頁面刷新!
這裏有什麼問題? 我很累,試圖....