Exemplo n.º 1
0
?>

<div class="championship-part-form">

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

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 255]);
?>
    
    <?php 
$availableChampionships = [];
if (!$model->isNewRecord) {
    $championship = Championship::findOne($model->championship_id);
    if (isset($championship->id)) {
        $availableChampionships = [$championship->id => $championship->name];
    }
}
echo $form->field($model, 'championship_id')->widget(SelectizeDropDownList::classname(), ['loadUrl' => Url::to(['championship/championship-part-list']), 'items' => $availableChampionships, 'options' => ['multiple' => false], 'clientOptions' => ['valueField' => 'value', 'labelField' => 'text', 'persist' => false]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Добавить' : 'Изменить', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
 /**
  * Finds the Championship model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Championship the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Championship::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }