/** * Key-value pairs of all categories * @return array [category_id => category_name] */ public static function all() { static $result; if (!is_null($result)) { return $result; } $command = Yii::app()->db; /* @var CDbConnection $command */ $rows = $command->createCommand()->select('id, name')->from(CvPositions::model()->tableName())->queryAll(); $result = []; foreach ($rows as $row) { $result[$row['id']] = $row['name']; } return $result; }
<table class="table"> <tr> <td> <?php echo $form->textFieldControlGroup($model, 'desired_position', array('span' => 10, 'maxlength' => 255)); ?> </td> <td> <?php echo $form->labelEx($model, 'desiredPositionsIds'); ?> <input type="text" name="desiredPositionsFilter" class="filter" size="10" /> <div class="div-overflow"> <?php echo $form->checkBoxList($model, 'desiredPositionsIds', CHtml::listData(CvPositions::model()->findAll(array('order' => 'name')), 'id', 'name')); ?> </div> </td> </tr> </table> <table class="table"> <tr> <td> <?php echo $form->labelEx($model, 'jobLocationsIds'); ?> <input type="text" name="jobLocationsFilter" class="filter" size="10" /> <div class="div-overflow"> <?php
echo CHtml::checkBoxList('categories', $categoriesFilter, CHtml::listData(CvCategories::model()->findAll(array('order' => getOrder($categoriesFilter) . 'name ASC')), 'id', 'name'), array('template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '')); ?> </div> </td> <td class="<?php echo getClassName($positionsFilter); ?> "> <strong><?php echo CHtml::encode(CvList::model()->getAttributeLabel('positionsIds')); ?> </strong><br /> <input type="text" name="positionsFilter" class="filter" size="10" /> <div class="div-overflow narrow"> <?php echo CHtml::checkBoxList('positions', $positionsFilter, CHtml::listData(CvPositions::model()->findAll(array('order' => getOrder($positionsFilter) . 'name ASC')), 'id', 'name'), array('template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '')); ?> </div> </td> <td class="<?php echo getClassName($assistanceIdsFilter); ?> "> <strong><?php echo CHtml::encode(CvList::model()->getAttributeLabel('assistanceIds')); ?> </strong><br /> <input type="text" name="assistanceFilter" class="filter" size="10" /> <div class="div-overflow narrow"> <?php echo CHtml::checkBoxList('assistanceIds', $assistanceIdsFilter, CHtml::listData(AssistanceTypes::model()->findAll(array('order' => getOrder($assistanceIdsFilter) . 'name ASC')), 'id', 'name'), array('template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => ''));