/** * Finds the PieceCategory model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return PieceCategory the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = PieceCategory::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
$form = ActiveForm::begin(); ?> <div class="box-body piece-form"> <?php echo $form->field($model, 'name', ['inputOptions' => ['class' => 'form-control', 'readonly' => $model->isNewRecord ? false : true]])->textInput(['maxlength' => true, 'placeholder' => '输入' . $model->getAttributeLabel('name')]); ?> <?php if ($model->isNewRecord) { ?> <?php echo $form->field($model, 'key')->textInput(['maxlength' => true, 'placeholder' => '输入' . $model->getAttributeLabel('key')]); ?> <?php echo $form->field($model, 'category_id')->textInput()->dropDownList(ArrayHelper::map(PieceCategory::find()->where(['status' => 1])->all(), 'id', 'title')); ?> <?php echo $form->field($model, 'description')->textarea(['rows' => 3]); ?> <?php echo $form->field($model, 'pre_url')->textInput(['maxlength' => true, 'placeholder' => '输入' . $model->getAttributeLabel('pre_url')]); ?> <?php echo $form->field($model, 'status')->textInput()->dropDownList(common\models\Common::getStatus()); ?> <?php } ?>