コード例 #1
0
 /**
  * @return array|string
  */
 public function actionCreate()
 {
     $model = new CountryRecord();
     $request = Yii::$app->request;
     if ($model->load($request->post())) {
         if ($request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->save()) {
             return $this->redirect(['country/index']);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
コード例 #2
0
ファイル: HotelRecord.php プロジェクト: lebeddima/booking
 /**
  * @return ActiveQuery
  */
 public function getCountry()
 {
     return $this->hasOne(CountryRecord::className(), ['id' => 'country_id']);
 }
コード例 #3
0
ファイル: _filter.php プロジェクト: lebeddima/booking
 * @var $hotelFilterForm \common\models\hotel\filter\HotelFilterForm
 * @var $search common\models\tour\TourRecord
 */
use common\models\country\CountryRecord;
use common\models\hotel\HotelRecord;
use common\models\tour\TourRecord;
?>

<div class="toolbar-2 form-inline">
    <?php 
$form = \yii\widgets\ActiveForm::begin(['method' => 'GET']);
?>
    <div class="form-group">

        <?php 
echo $form->field($hotelFilterForm, 'country_id')->dropDownList(CountryRecord::getCountries())->label(false);
?>
        <?php 
echo $form->field($search, 'hotel_id')->dropDownList(HotelRecord::getHotels())->label(false);
?>
        <?php 
echo $form->field($hotelFilterForm, 'stars')->dropDownList(HotelRecord::stars())->label(false);
?>
        <?php 
echo $form->field($hotelFilterForm, 'type')->dropDownList(HotelRecord::types())->label(false);
?>
        <?php 
echo $form->field($search, 'adults')->dropDownList(TourRecord::adults())->label(false);
?>
        <?php 
echo $form->field($search, 'children')->dropDownList(TourRecord::children())->label(false);
コード例 #4
0
ファイル: _form.php プロジェクト: lebeddima/booking
<?php

/* @var $model \common\models\country\CountryRecord */
use yii\bootstrap\ActiveForm;
$form = ActiveForm::begin(['layout' => 'horizontal']);
echo $form->field($model, 'name');
echo $form->field($model, 'description')->textarea(['cols' => 2, 'rows' => 3]);
echo $form->field($model, 'type')->dropDownList(\common\models\hotel\HotelRecord::types());
echo $form->field($model, 'stars')->dropDownList(\common\models\hotel\HotelRecord::stars());
echo $form->field($model, 'country_id')->dropDownList(\common\models\country\CountryRecord::getCountries());
?>

    <div class="clearfix form-actions">
        <div class="col-md-offset-3 col-md-9">
            <?php 
echo \yii\bootstrap\Html::submitButton('Применить', ['class' => 'btn btn-success']);
?>
        </div>
    </div>

<?php 
ActiveForm::end();