123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- use yii\helpers\Html;
- use yii\jui\DatePicker;
- use kartik\datetime\DateTimePicker;
- use yii\web\JsExpression;
- use yii\web\View;
- use yii\widgets\ActiveForm;
- /* @var $this yii\web\View */
- /* @var $model app\models\base\TopSlider */
- /* @var $form yii\widgets\ActiveForm */
- $formatJs = <<< 'JS'
- var formatRepo = function (repo) {
- if (repo.loading) {
- return repo.text;
- }
- var markup =
- '<div class="row">' +
- '<div class="col-sm-5">' +
- '<img src="' + repo.picture + '" class="img-rounded" style="width:160px;height:90px;" />' +
- '<b style="margin-left:5px">' + repo.title + '</b>' +
- '</div>' +
- '</div>';
- return '<div style="overflow:hidden;">' + markup + '</div>';
- };
- var formatRepoSelection = function (repo) {
- return repo.title;
- }
- JS;
- $this->registerJs($formatJs, View::POS_HEAD);
- $resultsJs = <<< JS
- function (data, params) {
- params.page = params.page || 1;
- return {
- results: data.items,
- pagination: {
- more: (params.page * 30) < data.total_count
- }
- };
- }
- JS;
- ?>
- <div class="top-slider-form">
- <?php $form = ActiveForm::begin(); ?>
- <?= $form->field($model, 'post_id')->widget( \kartik\select2\Select2::class,[
- "value"=>$model->post_id,
- 'initValueText' => !is_null($model->post)?$model->post->title:"asdasd",
- "options"=>["value"=>$model->post_id],
- 'pluginOptions' => [
- //'allowClear' => true,
- 'selectOnClose' => true,
- 'ajax' => [
- 'url' => \yii\helpers\Url::to(['/manager/top-slider/find-news']),
- 'dataType' => 'json',
- 'data' => new JsExpression('function(params) { return {q:params.term, page: params.page}; }'),
- 'processResults' => new JsExpression($resultsJs),
- 'cache' => true,
- 'delay' => 1000,
- ],
- 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
- 'templateResult' => new JsExpression('formatRepo'),
- 'templateSelection' => new JsExpression('formatRepoSelection'),
- ]
- ])->label('Новость')?>
- <div class="row">
- <div class="col-md-6">
- <?= $form->field($model, 'published_from')->widget(DateTimePicker::classname(), [
- 'name' => 'published_from',
- 'options' => ['class' => 'form-control'],
- 'convertFormat' => true,
- 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
- 'pluginOptions' => [
- 'format' => 'yyyy-MM-dd hh:i:s',
- 'startDate' => '2023-01-01 12:00',
- 'todayHighlight' => true,
- 'autoclose'=>true
- ]
- ])?>
- </div>
- <div class="col-md-6">
- <?= $form->field($model, 'published_to')->widget(DateTimePicker::classname(), [
- 'name' => 'published_to',
- 'options' => ['class' => 'form-control'],
- 'convertFormat' => true,
- 'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
- 'pluginOptions' => [
- 'format' => 'yyyy-MM-dd hh:i:s',
- 'startDate' => '2023-01-01 12:00',
- 'todayHighlight' => true,
- 'autoclose'=>true
- ]
- ])?>
- </div>
- </div>
- <?= $form->field($model, 'is_active')->checkbox() ?>
- <div class="form-group">
- <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
- </div>
- <?php ActiveForm::end(); ?>
- </div>
|