本文整理匯總了PHP中app\models\News::getCatOption方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::getCatOption方法的具體用法?PHP News::getCatOption怎麽用?PHP News::getCatOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\News
的用法示例。
在下文中一共展示了News::getCatOption方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
<div class="news-form">
<?php
$form = ActiveForm::begin();
?>
<?php
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
<!--
<//?= $form->field($model, 'cat')->textInput() ?>
-->
<?php
echo $form->field($model, 'cat')->dropDownList(News::getCatOption());
?>
<!--
<//?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>
-->
<?php
echo $form->field($model, 'content')->widget(Widget::className(), ['settings' => ['lang' => 'zh_cn', 'minHeight' => 200, 'maxHeight' => 400, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'plugins' => ['clips', 'fullscreen', 'fontcolor', 'fontfamily', 'fontsize', 'limiter', 'table', 'textexpander', 'textdirection', 'video', 'definedlinks', 'filemanager', 'imagemanager'], 'imageManagerJson' => Url::to(['/news/imagesget']), 'imageUpload' => Url::to(['/news/imageupload'])]]);
?>
<!--
<//?= $form->field($model, 'create_time')->textInput() ?>
示例2: function
use app\models\News;
/* @var $this yii\web\View */
/* @var $searchModel app\models\NewsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '新聞管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="news-index">
<h4><?php
echo Html::encode($this->title);
?>
</h4>
<?php
// echo $this->render('_search', ['model' => $searchModel]);
?>
<p>
<?php
echo Html::a('創建新聞', ['create'], ['class' => 'btn btn-success']);
?>
</p>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'showOnEmpty' => false, 'tableOptions' => ['class' => 'table table-striped'], 'columns' => ['news_id', 'title', 'create_time', ['attribute' => 'cat', 'label' => '分類', 'value' => function ($model, $key, $index, $column) {
return News::getCatOption($model->cat);
}, 'filter' => News::getCatOption(), 'headerOptions' => array('style' => 'width:90px;')], 'clickcnt', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>