/** * Key-value pairs of all cities * @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('city_index, city_name')->from(CitiesList::model()->tableName())->queryAll(); $result = []; foreach ($rows as $row) { $result[$row['city_index']] = $row['city_name']; } asort($result); return $result; }
echo $form->labelEx($model, 'salary'); ?> <?php echo $form->textField($model, 'salary', ['class' => 'span8', 'maxlength' => 255]); ?> <?php echo $form->error($model, 'salary'); ?> <?php echo $form->labelEx($model, 'jobLocationsIds'); ?> <div class="div-overflow"> <?php echo $form->checkBoxList($model, 'jobLocationsIds', CHtml::listData(CitiesList::model()->findAll(['order' => 'city_name']), 'city_index', 'city_name'), ['template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '']); ?> </div> <?php echo $form->error($model, 'jobLocationsIds'); ?> <?php echo $form->labelEx($model, 'documents'); ?> <?php echo $form->textArea($model, 'documents', ['rows' => 2, 'class' => 'span8']); ?> <?php echo $form->error($model, 'documents');
?> <input type="text" name="jobLocationsFilter" class="filter" size="10" /> <div class="div-overflow"> <?php echo $form->checkBoxList($model, 'jobLocationsIds', CHtml::listData(CitiesList::model()->findAll(array('order' => 'city_name')), 'city_index', 'city_name')); ?> </div> </td> <td> <?php echo $form->labelEx($model, 'residenciesIds'); ?> <input type="text" name="residenciesFilter" class="filter" size="10" /> <div class="div-overflow"> <?php echo $form->checkBoxList($model, 'residenciesIds', CHtml::listData(CitiesList::model()->findAll(array('order' => 'city_name')), 'city_index', 'city_name')); ?> </div> </td> </tr> </table> <?php echo $form->textFieldControlGroup($model, 'salary', array('span' => 5, 'maxlength' => 255)); ?> <?php echo $form->textAreaControlGroup($model, 'documents', array('rows' => 2, 'span' => 8)); ?> <?php
echo CHtml::checkBoxList('locations', $locationsFilter, CHtml::listData(CitiesList::model()->findAll(array('order' => getOrder($locationsFilter, 'city_index') . 'city_name ASC')), 'city_index', 'city_name'), array('template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '')); ?> </div> </td> <td class="<?php echo getClassName($residenciesFilter); ?> "> <strong><?php echo CHtml::encode(CvList::model()->getAttributeLabel('residenciesIds')); ?> </strong><br /> <input type="text" name="residenciesFilter" class="filter" size="10" /> <div class="div-overflow narrow"> <?php echo CHtml::checkBoxList('residencies', $residenciesFilter, CHtml::listData(CitiesList::model()->findAll(array('order' => getOrder($residenciesFilter, 'city_index') . 'city_name ASC')), 'city_index', 'city_name'), array('template' => '{beginLabel}{input} {labelTitle}{endLabel}', 'separator' => '')); ?> </div> </td> <td class="<?php echo getClassName($categoriesFilter); ?> "> <strong><?php echo CHtml::encode(CvList::model()->getAttributeLabel('categoryIds')); ?> </strong><br /> <input type="text" name="categoryFilter" class="filter" size="10" /> <div class="div-overflow narrow"> <?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' => ''));