| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 | <?phpuse backend\widgets\ActiveForm;use backend\widgets\meta\MetaForm;use common\behaviors\TagBehavior;use common\widgets\tag\TagsInput;use yii\helpers\Html;use common\models\Category;use common\helpers\Tree;use common\modules\attachment\widgets\SingleWidget;/* @var $this yii\web\View *//* @var $model common\models\Article *//* @var $moduleModel \common\models\article\Base *//* @var $form backend\widgets\ActiveForm */?><?php $form = ActiveForm::begin([    'enableClientValidation' => false,    'enableAjaxValidation' => true]); ?><div class="nav-tabs-custom">    <ul class="nav nav-tabs">        <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">基础信息</a></li>        <li><a href="#tab_2" data-toggle="tab" aria-expanded="true">扩展信息</a></li>    </ul>    <div class="tab-content">        <div class="tab-pane active" id="tab_1">            <?= $form->field($model, 'category_id')->dropDownList(Category::getDropDownList(Tree::build(Category::listsByType(0)))) ?>            <?= $form->field($model, 'chain')->checkboxList([]) ?>            <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>            <!--                    --><? //= $form->field($model, 'description')->textarea()?>            <?php foreach ($moduleModel->formAttributes() as $attribute): ?>                <?= $form->field($model, $attribute)->label($moduleModel->getAttributeLabel($attribute))->widget(\common\widgets\dynamicInput\DynamicInputWidget::className(), ['type' => $moduleModel->getAttributeType($attribute), 'data' => $moduleModel->getAttributeItems($attribute), 'options' => $moduleModel->getAttributeOptions($attribute)]) ?>            <?php endforeach; ?>            <?= $form->field($model, 'city')->textInput(['maxlength' => true]) ?>            <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>            <?= $form->field($model, 'tel')->textInput(['maxlength' => true]) ?>            <!--                    --><? //= $form->boxField($model, 'meta', ["collapsed" => true])->widget(MetaForm::className())->header("SEO"); ?>            <?= $form->field($model, 'sort')->textInput(['maxlength' => true]) ?>        </div>        <div class="tab-pane" id="tab_2">            <?= $form->field($model, 'published_at')->widget(                \kartik\datetime\DateTimePicker::className(),                [                    'type' => 1,                    'options' => [                        'value' => !empty($model->published_at) ? date('Y-m-d H:i:s', $model->published_at) : ''                    ],                    'pluginOptions' => ['autoclose' => true]                ]            ) ?>            <?= $form->field($model, 'cover')->widget(SingleWidget::className()) ?>            <!--                    --><? //= $form->field($model, 'commentEnabled')->checkbox(['label' => '开启评论']) ?>            <?= $form->field($model, 'is_top')->checkbox() ?>            <!--                    --><? //= $form->field($model, 'is_hot')->checkbox() ?>            <!--                    --><? //= $form->field($model, 'is_best')->checkbox() ?>            <?= $form->field($model, 'status')->checkbox() ?>            <?= $form->field($model, 'view')->textInput() ?>            <?= $form->field($model, TagBehavior::$formName)->label(TagBehavior::$formLable)->widget(TagsInput::className()) ?>            <!--                    --><? //= $form->field($model, 'source')->textInput() ?>        </div>    </div></div><div class="form-group form-submit">    <?= Html::submitButton($model->isNewRecord ? '保存' : '更新', ['class' => 'btn bg-maroon btn-flat btn-block']) ?></div><?php ActiveForm::end(); ?><?php$chain = \yii\helpers\Json::htmlEncode($model->chain);$js = <<<JS    function cidToggle() {        $.get('/admin/category/chain', {id: $('#article-category_id').val()}, (res) => {            let html = '';            res.data.forEach((item, index) => {                html += '<label>';                if ($chain && $chain.indexOf(item) != -1) {                    html += '<input type="checkbox" name="Article[chain][]" checked="checked" value="'+item+'">';                } else {                    html += '<input type="checkbox" name="Article[chain][]" value="'+item+'">';                }                html += '<span style="margin-right: 10px">'+item+'</span>';                html += '</label>';            })            $('#article-chain').html(html);        });    }        $('#article-category_id').change(function(e) {        cidToggle();    });           //初始化调用    cidToggle();        JS;$this->registerJs($js);?>
 |