I'm using the text field in advanced search. Now, I need to convert the text field 'Reviewed Date' into 2 radio buttons 'Reviewed' and 'Not reviewed'. Reviewed button should present all the rows with ReviwedDate not null and Reviewed with null values. I'm using the _search.php for this.
Change your search function in model:
public function search() {
$criteria = new CDbCriteria;
// ... other fields
// ADD THIS
if($this->reviewedDate != '') {
$criteria->addCondition(
'reviewedDate ' . ($this->reviewedDate=='1' ? 'IS NOT NULL' : 'IS NULL'),
);
}
else {
$criteria->addCondition('reviewedDate IS NULL');
}
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Change your _search.php:
<div class="row">
<?php echo $form->labelEx($model, 'reviewedDate'); ?>
<?php echo $form->radioButtonList($model, 'reviewedDate',
array('1' => 'Reviewed', '' => 'Not Reviewed')
); ?>
</div>