Beispiel #1
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
echo $form->dropDownListControlGroup($model, 'category_id', CHtml::listData(WeblinkCategory::model()->findAll(array('condition' => 'published=1', "order" => "title")), 'id', 'title'), array('empty' => '--please select--', 'class' => 'span5'));
echo $form->textFieldControlGroup($model, 'title', array('class' => 'span5', 'maxlength' => 255));
echo $form->dropDownListControlGroup($model, 'published', array('1' => 'Yes', '0' => 'No'));
?>
<div class="form-actions">
    <?php 
echo TbHtml::submitButton('Search', array('color' => TbHtml::BUTTON_COLOR_PRIMARY));
?>
    <?php 
echo TbHtml::resetButton('Reset', array('color' => TbHtml::BUTTON_COLOR_INFO));
?>
</div>
<?php 
$this->endWidget();
Beispiel #2
0
        </div>
        <div class="widget-toolbar">
            <?php 
echo CHtml::link('<i class="icon-search"></i>', '#', array('class' => 'search-button', 'data-rel' => 'tooltip', 'title' => 'Search', 'data-placement' => 'bottom'));
?>
        </div>
    </div><!--/.widget-header -->
    <div class="widget-body">
        <div class="widget-main">
            <div class="search-form" style="display:none">
                <?php 
$this->renderPartial('_search', array('model' => $model));
?>
            </div><!-- search-form -->
            <?php 
$this->widget('bootstrap.widgets.TbGridView', array('type' => TbHtml::GRID_TYPE_HOVER, 'id' => 'weblink-category-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'parent_id', 'type' => 'raw', 'value' => 'getCategoryName($data->parent_id)', 'filter' => CHtml::activeDropDownList($model, 'parent_id', CHtml::listData(WeblinkCategory::model()->findAll(array('condition' => 'parent_id=0', "order" => "title")), 'id', 'title'), array('empty' => 'All')), 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Parent Category')), 'title', array('name' => 'description', 'type' => 'raw', 'value' => '$data->description', 'htmlOptions' => array('style' => "text-align:left;", 'title' => 'Description')), array('name' => 'published', 'header' => "Status", 'value' => '$data->published?Yii::t(\'app\',\'Active\'):Yii::t(\'app\', \'Inactive\')', 'filter' => array('' => Yii::t('app', 'All'), '0' => Yii::t('app', 'Inactive'), '1' => Yii::t('app', 'Active')), 'htmlOptions' => array('style' => "text-align:center;")), array('header' => 'Actions', 'class' => 'bootstrap.widgets.TbButtonColumn'))));
/**
 * Retrieves Category name by ID.
 * @return string.
 */
function getCategoryName($id)
{
    $returnValue = Yii::app()->db->createCommand()->select('title')->from('{{weblink_category}}')->where('id=:id', array(':id' => $id))->queryScalar();
    if ($returnValue <= '0') {
        $returnValue = 'No parent!';
    } else {
        $returnValue = $returnValue;
    }
    return $returnValue;
}
?>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = WeblinkCategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }