/** * Formulaire de création */ use app\modules\cms\HCms; use app\modules\cms\models\BasePage; use app\modules\cms\widgets\BasePageForm; use yii\helpers\Html; /** * @var yii\web\View $this * @var BasePage $model */ $this->title = HCms::t('labels', 'Create a new base page'); ?> <div class="row panel panel-default"> <div class="panel-heading"> <h1><?php echo Html::encode($this->title); ?> </h1> </div> <div class="panel-body"> <?php echo BasePageForm::widget(['model' => $model]); ?> </div> </div>
/** * Renvoie le code HTML du formulaire associée à la BasePage d'identifiant $id * * @param int $id * @return mixed */ public function actionGetForm($id) { $model = $this->findModel($id); return BasePageForm::widget(['model' => $model, 'asNestedForm' => true]); }
$this->registerJs("\n \$('#webpage-base_id').change(function() {\n var url = '/cms/base-pages/get-form/' + \$(this).val();\n \$('#base-model-display').load(url, function() {\n \$('#base_texts_ids').select2({\n placeholder: \"{$placeHolderMsg}\",\n tags: true\n });\n });\n });\n"); ?> <div class="backend-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'base_id')->dropDownList(ArrayHelper::map($basePages, 'id', 'code'), ['prompt' => HLib::t('messages', 'Select a value in the list')]); ?> <fieldset id="base-model-display"> <?php echo BasePageForm::widget(['model' => $baseModel, 'asNestedForm' => true]); ?> </fieldset> <fieldset> <div class="row"> <div class="col-sm-4"> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> </div> <div class="col-sm-4"> <?php echo $form->field($model, 'menu_title')->textInput(['maxlength' => true]); ?> </div>