/** * Finds the MarcaVeiculo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MarcaVeiculo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MarcaVeiculo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="veiculo-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'nomeveiculo')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'cor')->textInput(['maxlength' => true, 'style' => 'width:200px']); ?> <?php echo $form->field($model, 'idmarcaveiculo')->dropDownList(ArrayHelper::map(MarcaVeiculo::find()->all(), 'idmarcaveiculo', 'nomemarca'), ['prompt' => 'Selecione uma marca', 'style' => 'width:200px']); ?> <table> <tr> <td> <?php echo $form->field($model, 'anofabricacao')->textInput(['maxlength' => 4, 'style' => 'width:150px', 'integerOnly' => true]); ?> </td> <td> <?php echo $form->field($model, 'anomodelo')->textInput(['maxlength' => 4, 'style' => 'width:150px', 'integerOnly' => true]); ?> </td> </tr>