示例#1
0
 /**
  * Lists all LinkType models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => LinkType::find()->alive()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
示例#2
0
文件: index.php 项目: jorry2008/turen
	                <p>
	                    <?php 
echo Html::a(Yii::t('extend', 'Create Link'), ['create'], ['class' => 'btn btn-success']);
?>
	                </p>
	             -->
            	<?php 
Pjax::begin();
?>
				<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'raw', 'value' => function ($model) {
    $length = Yii::$app->params['config']['config_site_title_length'];
    $title = StringHelper::truncate($model->name, $length);
    //'<span class="fa fa-list-ol"></span> '.
    return Html::a($title, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], ['attribute' => 'link_type_id', 'filter' => ArrayHelper::map(LinkType::find()->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->linkType->name;
}], 'link_url:url', ['attribute' => 'order', 'format' => 'raw', 'value' => function ($model) {
    return Html::activeTextInput($model, 'order', ['style' => 'width:50px', 'data-id' => $model->id, 'id' => '', 'class' => 'cms-order']);
}], ['attribute' => 'status', 'format' => 'html', 'filter' => [Link::STATUS_YES => Yii::t('common', 'Yes'), Link::STATUS_NO => Yii::t('common', 'No')], 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('common', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('common', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'header' => Yii::t('common', 'Opration')]]]);
?>
				<?php 
Pjax::end();
?>
                </div>
                
            </div>
示例#3
0
文件: _form.php 项目: jorry2008/turen
/* @var $model common\models\extend\Link */
/* @var $form yii\widgets\ActiveForm */
if ($model->isNewRecord) {
    $model->status = true;
    $model->order = 10;
}
?>

<div class="row link-form">
    <div class="col-md-12">
        <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldConfig' => ['template' => "{label} {beginWrapper} {input} {hint} {error} {endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-2', 'offset' => 'col-sm-offset-2', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]);
?>
    
        <?php 
echo $form->field($model, 'link_type_id')->dropDownList(ArrayHelper::map(LinkType::find()->alive()->all(), 'id', 'name'));
?>

	    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'link_url')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('extend', 'Example:http://www.turen.pw'))->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'description')->textarea(['maxlength' => true]);
?>
	    
	    <?php