Ejemplo n.º 1
0
}
?>

<div class="row cms-ad-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, 'ad_type_id')->dropDownList(ArrayHelper::map(AdType::find()->alive()->all(), 'id', 'name'));
?>
        
        <?php 
echo $form->field($model, 'mode')->dropDownList(Ad::getAdMode());
?>

	    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'short_code')->textInput(['maxlength' => true]);
?>
	    
	    <?php 
echo $form->field($model, 'pic_url')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('fileinput', 'Note: Limit upload one picture.'))->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => false], 'pluginOptions' => ['uploadUrl' => Url::to(['/cms/ad/file-upload']), 'uploadAsync' => true, 'initialPreview' => General::showImages($model->pic_url), 'initialPreviewConfig' => General::showLinks($model->pic_url, 'pic_url', 'ad', '/cms/ad/file-upload'), 'previewFileType' => 'any', 'overwriteInitial' => true, 'maxFileSize' => Yii::$app->params['config']['config_pic_size'], 'allowedFileExtensions' => explode(',', Yii::$app->params['config']['config_pic_extension']), 'allowedFileTypes' => ['image'], 'maxFileCount' => 1, 'uploadExtraData' => ['dir' => 'ad', 'name' => 'Ad[pic_url]', 'route' => '/cms/ad/file-upload', 'field' => 'pic_url']]]);
?>
	    
	    <?php 
Ejemplo n.º 2
0
echo Html::a(Yii::t('cms', 'Create Ad'), ['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' => 'title', 'format' => 'raw', 'value' => function ($model) {
    $length = Yii::$app->params['config']['config_site_title_length'];
    $title = StringHelper::truncate($model->title, $length);
    return Html::a($title, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], 'short_code', ['attribute' => 'ad_type_id', 'filter' => ArrayHelper::map(AdType::find()->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->adType->name;
}], ['attribute' => 'mode', 'format' => 'raw', 'filter' => Ad::getAdMode(), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $modes = Ad::getAdMode();
    return empty($modes[$model->mode]) ? '' : $modes[$model->mode];
}], ['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' => [Ad::STATUS_YES => Yii::t('cms', 'Yes'), Ad::STATUS_NO => Yii::t('cms', '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('cms', '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('cms', '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>