0

我使用下面的代码在高级搜索表单中创建了 4 个单选按钮。

<div class="row">
        <?php #echo $form->label($model,'ReviewedDate'); ?>     
                <?php echo $form->radioButtonList($model, 'ReviewedDate', 
        array('1' => 'Reviewed', '' => 'Not Reviewed')
    ); ?>
    </div>

       <div class="row"> 
                <?php echo $form->radioButtonList($model, 'Approved', 
        array('0' => 'Rejected', '1' => 'Approved')
    ); ?> 
    </div>   

所以现在我在模型中创建了一些标准,用于过滤 gridview 以根据单选按钮值显示行。

if($this->ReviewedDate != '') 
                {
                $criteria->addCondition('ReviewedDate ' . ($this->ReviewedDate=='1' ? 'IS NOT NULL' : 'IS NULL'));
                $criteria->addCondition('updateddate > createddate');
                $criteria->compare('revieweddate','0000-00-00 00:00:00');
                }
                else 
                {
                $criteria->addCondition('updateddate = createddate');    
                $criteria->addCondition('ReviewedDate IS NULL');
                }



if (isset($this->Approved) && !empty($this->Approved)) {

                        $criteria->addCondition("approved='" . $this->Approved . "'");
                        $criteria->condition = ' (updateddate > createddate) AND (revieweddate IS NOT NULL) and approved = 1 ';
                }
                else {

                        $criteria->addCondition("approved='" . $this->Approved . "'");
                        $criteria->condition = ' (updateddate > createddate) AND (revieweddate IS NOT NULL) and approved = 0 ';
                }

如果评论了 reviewdate 标准或评论了批准的标准,上面的代码可以正常工作并相应地显示行。但是,这两个标准不能同时起作用。当我尝试同时使用这两个标准时,其中一个标准有效。
1. 现在,我想为每个选项创建单独的单选按钮(我需要 4 个已批准、拒绝、已审核、未审核的单选按钮)。
2. 我希望单选按钮适用于每个条件而不会重叠。
我怎样才能做到这一点

4

1 回答 1

0

通过设置$criteria->condition,您可以有效地撤消所有addConditioncompare调用。请改用另一个addCondition电话。

于 2013-09-26T06:37:35.747 回答