<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use mdm\admin\models\Menu;
use yii\helpers\Json;
use mdm\admin\AutocompleteAsset;
/* @var $this yii\web\View */
/* @var $model mdm\admin\models\Menu */
/* @var $form yii\widgets\ActiveForm */
AutocompleteAsset::register($this);
$opts = Json::htmlEncode(['menus' => Menu::getMenuSource(), 'routes' => Menu::getSavedRoutes()]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
?>

<div class="menu-form">
    <?php 
$form = ActiveForm::begin();
?>
    <?php 
echo Html::activeHiddenInput($model, 'parent', ['id' => 'parent_id']);
?>
    <div class="row">
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 128]);
?>

            <?php 
echo $form->field($model, 'parent_name')->textInput(['id' => 'parent_name']);
Example #2
0
?>

    <?php 
echo $form->field($model, 'route')->textInput(['id' => 'route']);
?>

    <?php 
echo $form->field($model, 'order')->input('number');
?>

    <?php 
echo $form->field($model, 'data')->textarea(['rows' => 4]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('rbac-admin', 'Create') : Yii::t('rbac-admin', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
<?php 
AutocompleteAsset::register($this);
$options1 = Json::htmlEncode(['source' => Menu::find()->select(['name'])->column()]);
$this->registerJs("\$('#parent_name').autocomplete({$options1});");
$options2 = Json::htmlEncode(['source' => Menu::getSavedRoutes()]);
$this->registerJs("\$('#route').autocomplete({$options2});");
Example #3
0
<div class="menu-form">

    <?php 
$form = ActiveForm::begin(['id' => 'menu-form', 'options' => ['enctype' => 'multipart/form-data', 'class' => 'form-horizontal'], 'enableClientValidation' => true, 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-9\">{input}</div>\n<div class=\"col-lg-offset-3 col-lg-9\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-3 control-label']]]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'parent_name')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Menu::find()->select(['name'])->column()]]);
?>

    <?php 
echo $form->field($model, 'route')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => Menu::getSavedRoutes()]]);
?>

    <?php 
echo $form->field($model, 'order')->input('number');
?>

    <?php 
echo $form->field($model, 'data')->widget(\common\widgets\Iconpicker::className(), ['rows' => 6, 'columns' => 8, 'iconset' => 'fontawesome'])->label('请选择一个图标..');
?>

    <div class="form-group">
        <div class="col-lg-offset-3">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('rbac-admin', 'Create') : Yii::t('rbac-admin', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
Example #4
0
 public function actionValues()
 {
     return ['menus' => Menu::find()->asArray()->all(), 'routes' => Menu::getSavedRoutes()];
 }