You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.4 KiB
95 lines
2.4 KiB
6 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by Error202
|
||
|
* Date: 10.07.2018
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @var $this \yii\web\View
|
||
|
* @var $model \core\forms\menu\MenuItemForm
|
||
|
*/
|
||
|
|
||
|
use yii\widgets\ActiveForm;
|
||
|
use yii\helpers\Html;
|
||
|
use yii\web\JsExpression;
|
||
|
use yii\helpers\Url;
|
||
|
|
||
|
$block_name = Yii::t('page', 'Pages');
|
||
|
$block_title_attr = Yii::t('page', 'Pages');
|
||
|
|
||
|
$js = <<<JS
|
||
|
function updatePagesUrl() {
|
||
|
var select = $("#page_select");
|
||
|
var data = select.select2('data');
|
||
|
var selected_post = select.val();
|
||
|
$("#page_menu_item_url").val('/pages/page/view/');
|
||
|
$("#page_menu_item_url_params").val('{"id":'+selected_post+'}');
|
||
|
$("#page_menu_item_name").val(data[0].text);
|
||
|
$("#page_menu_item_title_attr").val(data[0].text);
|
||
|
}
|
||
|
JS;
|
||
|
$this->registerJs($js, $this::POS_HEAD);
|
||
|
|
||
|
$fetchUrl = Url::to( [ '/pages/manage/page/page-search' ] );
|
||
|
?>
|
||
|
|
||
|
<div class="menu_item_widget">
|
||
|
|
||
|
<div class="form-group">
|
||
|
<div>
|
||
|
<?= \kartik\widgets\Select2::widget([
|
||
|
'name' => 'page_select',
|
||
|
'value' => '',
|
||
|
'options' => [
|
||
|
'placeholder' => Yii::t('page', 'Select page...'),
|
||
|
'id' => 'page_select',
|
||
|
'onchange' => new JsExpression("updatePagesUrl()"),
|
||
|
],
|
||
|
'pluginOptions' => [
|
||
|
'ajax' => [
|
||
|
'url' => $fetchUrl,
|
||
|
'dataType' => 'json',
|
||
|
'data' => new JsExpression('function(params) { return {q:params.term}; }')
|
||
|
],
|
||
|
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
|
||
|
'templateResult' => new JsExpression('function(tag) { return tag.text; }'),
|
||
|
'templateSelection' => new JsExpression('function (tag) { return tag.text; }'),
|
||
|
],
|
||
|
]) ?>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<?php $form = ActiveForm::begin(); ?>
|
||
|
|
||
|
<?= $form->field($model, 'name')->hiddenInput([
|
||
|
'id' => 'page_menu_item_name',
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<?= $form->field($model, 'title_attr')->hiddenInput([
|
||
|
'id' => 'page_menu_item_title_attr',
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<?= $form->field($model, 'module')->hiddenInput([
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<?= $form->field($model, 'menu_id')->hiddenInput([
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<?= $form->field($model, 'url')->hiddenInput([
|
||
|
'id' => 'page_menu_item_url',
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<?= $form->field($model, 'url_params')->hiddenInput([
|
||
|
'value' => '',
|
||
|
'id' => 'page_menu_item_url_params',
|
||
|
])->label(false) ?>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<?= Html::submitButton(Yii::t('buttons', 'Add to menu'), [
|
||
|
'class' => 'btn btn-info btn-sm pull-right'
|
||
|
]) ?>
|
||
|
</div>
|
||
|
|
||
|
<?php ActiveForm::end(); ?>
|
||
|
|
||
|
</div>
|