public function init()
 {
     parent::init();
     if ($this->modelClass === null) {
         $this->modelClass = Country::className();
     }
 }
示例#2
0
/* @var $this yii\web\View */
/* @var $model nullref\geo\models\Region */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="region-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'country_id')->dropDownList(Country::getDropDownArray(), ['prompt' => Yii::t('geo', 'Choose country')])->label(Yii::t('geo', 'Country'));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('geo', 'Create') : Yii::t('geo', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
示例#3
0
 public function getCountry()
 {
     return $this->hasOne(Country::className(), ['id' => 'country_id']);
 }