本文整理匯總了PHP中common\models\Category::getCategoryList方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::getCategoryList方法的具體用法?PHP Category::getCategoryList怎麽用?PHP Category::getCategoryList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\Category
的用法示例。
在下文中一共展示了Category::getCategoryList方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
/**
* Updates an existing CategoryModel model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->updated_at = time();
$model->scenario = 'update';
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->categoryArray = CategoryCommon::getCategoryList();
return $this->render('update', ['model' => $model]);
}
}
示例2:
/* @var $model backend\models\News */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="news-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'category_id')->dropDownList(Category::getCategoryList(), ['prompt' => 'Please select the category'])->label('The Category');
?>
<?php
echo $form->field($model, 'description')->textInput(['maxlength' => true]);
?>
<?php
echo $form->field($model, 'content')->textarea(['rows' => 6]);
?>
<div class="form-group">
<?php
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
</div>