Example #1
0
 public function actionCreate($type = null)
 {
     $model = new Form();
     $model->type = $type;
     $model->siteId = Yii::$app->cmgCore->siteId;
     $model->setScenario('create');
     if ($model->load(Yii::$app->request->post(), 'Form') && $model->validate()) {
         if (FormService::create($model)) {
             $this->redirect($this->returnUrl);
         }
     }
     $templatesMap = TemplateService::getIdNameMapByType(CoreGlobal::TYPE_FORM);
     $templatesMap = ArrayHelper::merge(['0' => 'Choose Template'], $templatesMap);
     return $this->render('@cmsgears/module-core/admin/views/form/create', ['model' => $model, 'templatesMap' => $templatesMap, 'visibilityMap' => Form::$visibilityMap]);
 }
Example #2
0
 /**
  * @return array - ModelForm associated with parent
  */
 public function getForms()
 {
     return $this->hasMany(Form::className(), ['id' => 'formId'])->viaTable(CoreTables::TABLE_MODEL_FORM, ['parentId' => 'id'], function ($query) {
         $ModelFormTable = CoreTables::TABLE_MODEL_FORM;
         $query->onCondition(["{$ModelFormTable}.parentType" => $this->formType]);
     });
 }
Example #3
0
 public function getTag()
 {
     return $this->hasOne(Form::className(), ['id' => 'formId']);
 }
Example #4
0
 /**
  * @param string $slug
  * @return Form
  */
 public static function findBySlug($slug)
 {
     return Form::findBySlug($slug);
 }