common\models\Store::getKeyValuePairs PHP Method

getKeyValuePairs() public static method

public static getKeyValuePairs ( $schoolId )
    public static function getKeyValuePairs($schoolId)
    {
        $sql = 'SELECT id, name FROM ' . self::tableName() . ' WHERE school_id=:school_id ORDER BY name ASC';
        return Yii::$app->db->createCommand($sql, [':school_id' => $schoolId])->queryAll(\PDO::FETCH_KEY_PAIR);
    }

Usage Example

Esempio n. 1
0
use common\models\School;
$this->title = $model->isNewRecord ? '添加营业点用户' : '更新营业点用户';
?>
<div class="row">
    <div class="col-lg-6">
    <?php 
$form = ActiveForm::begin(['enableAjaxValidation' => true, 'options' => ['autocomplete' => 'off']]);
?>
        <div class="form-group">
            <label class="control-label">学校</label>
            <?php 
echo Html::dropDownList('school', $model->isNewRecord ? '' : $model->store->school_id, School::getKeyValuePairs(), ['class' => 'form-control']);
?>
        </div>
        <?php 
echo $form->field($model, 'store_id')->dropDownList($model->isNewRecord ? [] : Store::getKeyValuePairs($model->store->school_id));
?>
        <?php 
echo $form->field($model, 'username')->textInput(['autocomplete' => 'off']);
?>
        <?php 
echo $form->field($model, 'password')->passwordInput(['autocomplete' => 'off']);
?>
        <?php 
echo $form->field($model, 'email')->input('email');
?>
        <?php 
echo $form->field($model, 'real_name');
?>
        <?php 
echo $form->field($model, 'gender')->dropDownList(Admin::getGenderList());
All Usage Examples Of common\models\Store::getKeyValuePairs