common\models\School::getKeyValuePairs PHP Method

getKeyValuePairs() public static method

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

Usage Example

Example #1
0
       'pluginOptions' => [
           'allowClear' => true,
           'minimumInputLength' => 3,
           'ajax' => [
               'url' => Url::to(['/school/name-filter']),
               'dataType' => 'json',
               'data' => new JsExpression('function(params) { return {q:params.term}; }')
           ],
           'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
           'templateResult' => new JsExpression('function (store) { return store.text; }'),
           'templateSelection' => new JsExpression('function (store) { return store.text; }'),
       ]
   ])*/
?>
        <?php 
echo $form->field($model, 'school_id')->dropDownList(School::getKeyValuePairs());
?>
        <?php 
echo $form->field($model, 'address');
?>
        <?php 
echo $form->field($model, 'cellphone');
?>
        <?php 
echo $form->field($model, 'telephone');
?>
        <?php 
echo $form->field($model, 'hours');
?>
        <?php 
echo $form->field($model, 'enable_sms')->checkbox();
All Usage Examples Of common\models\School::getKeyValuePairs