Exemplo n.º 1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getClass()
 {
     return $this->hasOne(HotelClass::className(), ['id' => 'class_id']);
 }
Exemplo n.º 2
0
use app\modules\hotel\models\HotelClass;
use kartik\select2\Select2;
use toxor88\switchery\Switchery;
/* @var $this yii\web\View */
/* @var $model app\modules\hotel\models\HotelCategory */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="hotel-category-form">

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

    <?php 
echo $form->field($model, 'class_id')->widget(Select2::classname(), ['language' => 'ru', 'value' => 0, 'data' => ArrayHelper::map(HotelClass::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select provinces ...'], 'pluginOptions' => ['allowClear' => TRUE]]);
?>

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

    <?php 
echo $form->field($model, 'status')->widget(Switchery::classname(), ['clientOptions' => ['color' => '#64bd63', 'secondaryColor' => '#dfdfdf', 'jackColor' => '#fff', 'jackSecondaryColor' => null, 'className' => 'switchery js-switch', 'disabled' => false, 'disabledOpacity' => 0.5, 'speed' => '0.3s', 'size' => 'default']])->label(false);
?>



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