Yii中POS和GET并用范例

页面

<?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'add-form',
        'enableAjaxValidation'=>false,
        'method'=>'post',
        'action'=>$this->createUrl($this->route, array('username'=>$model->name, 'domain'=>$model->domain)),
)); ?>
    
        <?php echo $form->textArea($input, "mail", array("rows" => "10", "cols" => "100", "style"=>"ime-mode:disabled;"));?>  

        <?php echo CHtml::button('追加', 
                array(
                    'confirm'=>'确认消息',
                    'submit'=>array(),
                    'params'=>array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken, "add" => 1),
                    'class'=>'button',
                    )); 
        ?>

        <?php echo CHtml::button('検索', 
                array(
                    'submit'=>array(),
                    'params'=>array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken, "search" => 1),
                    'class'=>'button',
                    )); 
        ?>
    </p>
    
<?php $this->endWidget(); ?>

控制器:

if (!isset($_GET['username']) || !isset($_GET['domain'])) {
    if (isset($_POST["addmail"])) {
        Yii::log("追加  " . $_POST["Input"]["mail"]) ;
        
    } 
    if (isset($_POST["search"])) {
        Yii::log("検索  " .  $_POST["Input"]["mail"]) ;
    } 
}

相关推荐