コード例 #1
0
 /**
  * Finds the Stadium model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Stadium the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Stadium::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: _form.php プロジェクト: alexsynytskiy/Dynamomania
echo $form->field($model, 'season_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Season::find()->orderBy(['id' => SORT_DESC])->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите сезон...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'championship_part_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(ChampionshipPart::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите этап турнира...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
$availableStadiums = [];
if (!$model->isNewRecord) {
    $stadium = Stadium::findOne($model->stadium_id);
    if (isset($stadium->id)) {
        $availableStadiums = [$stadium->id => $stadium->name];
    }
}
echo $form->field($model, 'stadium_id')->widget(SelectizeDropDownList::classname(), ['loadUrl' => Url::to(['stadium/stadium-list']), 'items' => $availableStadiums, 'options' => ['multiple' => false], 'clientOptions' => ['valueField' => 'value', 'labelField' => 'text', 'persist' => false]]);
?>
        </div>
        
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'date')->widget(DateTimePicker::classname(), ['options' => ['placeholder' => 'Выберите дату матча'], 'removeButton' => false, 'language' => 'ru-RU', 'pluginOptions' => ['language' => 'ru', 'autoclose' => true, 'format' => 'dd.mm.yyyy hh:ii']]);
?>
        </div>
    </div>