Creates a new target model.
If creation is successful, the browser will be redirected to the 'view' page.
@return \yii\web\Response|string
511134
public function actionCreate()
    {
        $model = Yii::createObject($this->getModelClass());

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            \Yii::$app->getSession()->setFlash('success', $this->getFlashMsg('success'));
            return $this->redirect(ArrayHelper::merge(['view'], $model->getPrimaryKey(true)));
        } else {
            if ($model->hasErrors()) {
                \Yii::$app->getSession()->setFlash('error', $this->getFlashMsg('error'));
            }
            return $this->render($this->viewID, [
                'model' => $model,
            ]);
        }
    }
113212
public function actionCreate()
    {
        $model = new UserAuthItem(null);
        $model->type = $this->type;
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('yuncms','Create success.'));
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model]);
        }
    }
546376
public function actionCreate()
	{
		$model=new Post;
		if(isset($_POST['Post']))
		{
			$model->attributes=$_POST['Post'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
693545
public function actionWebsite()
    {
        $model = new SettingWebsiteForm();
        if (yii::$app->getRequest()->getIsPost()) {
            if ($model->load(yii::$app->getRequest()->post()) && $model->validate() && $model->setWebsiteConfig()) {
                yii::$app->getSession()->setFlash('success', yii::t('cms', 'Success'));
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0] . '<br>';
                }
                yii::$app->getSession()->setFlash('error', $err);
            }
        }

        $model->getWebsiteSetting();
        return $this->render('website', [
            'model' => $model
        ]);

    }
263871
public function actionCreate()
    {
        $model = new Z1User();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', '添加成功');
            return \myzero1\layui\helpers\Tool::redirectParent(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
348167
protected function createModel()
    {
        $tracker = $this->loader->getTracker();
        $model   = $tracker->getRespondentTrackModel();

        if (! $this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) {
            if (! $this->respondentTrack) {
                $this->respondentTrack = $tracker->getRespondentTrack($this->respondentTrackId);
            }
            $this->trackEngine = $this->respondentTrack->getTrackEngine();
        }
        $model->applyEditSettings($this->trackEngine);

        return $model;
    }
257713
public function actionCreate()
    {
        $model = new AuthItem(null);
        $model->type = Item::TYPE_ROLE;
        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            $model->load(\Yii::$app->request->post());
            \Yii::$app->response->format = Response::FORMAT_JSON;
            return ActiveForm::validate($model);
        }
        if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
            return $this->redirect(['view', 'id' => $model->name]);
        } else {
            return $this->render('create', ['model' => $model,]);
        }
    }
522487
public function actionCreate()
    {
        $model = Yii::createObject($this->modelClass);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->session->setFlash('success', Yii::t('yii2mod.cms', 'Page has been created.'));

            return $this->redirect(['index']);
        }

        return $this->render($this->createView, [
            'model' => $model,
        ]);
    }
676830
protected function createModel()
    {
        $model = $this->loader->getTracker()->getTrackModel();
        $model->applyFormatting(true, true);

        return $model;
    }
1151790
public function create()
    {
        // Look for overriden views
        $this->overrideViews();

        // Pass validation through
        Former::withRules($this->getRules());

        // Initialize localization
        with($localize = new Localize)
            ->model($this->model)
            ->title(Str::singular($this->title));

        // Make the sidebar
        $sidebar = new Sidebar;
        if (!$localize->hidden()) {
            $sidebar->addToEnd($localize);
        }

        // Render view
        return $this->populateView($this->show_view, [
            'item' => null,
            'localize' => $localize,
            'sidebar' => $sidebar,
            'parent_id' => $this->parent ? $this->parent->getKey() : null,
        ]);
    }
595848
public function actionCreate()
    {
        if ((Authentication::findOne(['user_id' => Yii::$app->user->id])) != null || Authentication::isAuthentication(Yii::$app->user->id)) {
            return $this->redirect(['index']);
        }
        $model = new Authentication();
        $model->scenario = Authentication::SCENARIO_CREATE;
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['index']);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
471623
public function actionCreate()
    {
        $model = new SeoPresets();
        $model->loadDefaultValues();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            if(Yii::$app->request->post('action') === 'apply') {
                return $this->redirect(['update', 'id' => $model->id]);
            }else{
                return $this->redirect(['view', 'id' => $model->id]);
            }
        }

        return $this->render('create', [
            'model' => $model,
        ]);
    }
386603
public function createAction()
    {
        // Load form
        $entityClass = $this->getModuleNamespace() . '\Entity\\' . $this->getEntityName();
        $entity      = new $entityClass();
        $form        = $this->getForm('Create' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Create account
            $result = $this->getService()->create();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/create');

        return $viewModel;
    }
1289416
public function actionCreate()
    {//echo __METHOD__."@{$this->module->className()}";
        //$model = new News();
        $model = $this->module->model('News');//var_dump($model->className());
        $model = $model->loadDefaultValues();
        //$modelsI18n = News::prepareI18nModels($model);
        $modelsI18n = $model::prepareI18nModels($model);//var_dump($modelsI18n);exit;

        $activeTab = $this->langCodeMain;

        $created = $this->savePost($model, $modelsI18n);
        if (!$created) {
            return $this->render('create', [
                'model' => $model,
                'modelsI18n' => $modelsI18n,
                'activeTab' => $activeTab,
            ]);
        } else if ($activeTab = $this->modelsHaveErrors($model, $modelsI18n)) { // main record created but exist another errors
            Yii::$app->session->setFlash('warning', Yii::t($this->tcModule, 'Record create but partially'));
            if ($activeTab === true) $activeTab = $this->langCodeMain;
            $errors = $model->errors;
            foreach($modelsI18n as $langCode => $modelI18n) {
                if ($modelI18n->hasErrors()) {
                    $errors += $modelI18n->errors;
                    $activeTab = $langCode;
                    break;
                }
            }
            $error = array_shift($errors); // get only first error
            if (isset($error[0])) {
                Yii::$app->session->setFlash('error', $error[0]);
            }
            return $this->redirect(['update',
                'id' => $model->id,
                'activeTab' => $activeTab,
            ]);
        } else {
            Yii::$app->session->setFlash('success', Yii::t($this->tcModule, 'Record create success'));
            if ($model->aftersave == $model::AFTERSAVE_VIEW) {
                return $this->redirect(['view', 'id' => $model->id]);
            } else {
                return $this->redirect(['index',
                    'page' => $model->page,
                    'id' => $model->id,
                    'sort' => $model->orderBy,
                    //'lang' => Yii::$app->language,
                ]);
            }
        }
    }
1005402
public function actionUpdate()
    {
        $model = $this->findModel();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            \Yii::$app->getSession()->setFlash('success', $this->getFlashMsg('success'));
            return $this->redirect(ArrayHelper::merge(['view'], $model->getPrimaryKey(true)));
        } else {
            if ($model->hasErrors()) {
                \Yii::$app->getSession()->setFlash('error', $this->getFlashMsg('error'));
            }
            return $this->render($this->viewID, [
                'model' => $model,
            ]);
        }
    }
139051
public function actionCreate()
    {
        /** @var User $user */
        $user = \Yii::createObject([
            'class'    => User::className(),
            'scenario' => 'create',
        ]);
        $event = $this->getUserEvent($user);

        $this->performAjaxValidation($user);

        $this->trigger(self::EVENT_BEFORE_CREATE, $event);
        if ($user->load(\Yii::$app->request->post()) && $user->create()) {
            \Yii::$app->getSession()->setFlash('success', \Yii::t('user', 'User has been created'));
            $this->trigger(self::EVENT_AFTER_CREATE, $event);
            return $this->redirect(['update', 'id' => $user->id]);
        }

        return $this->render('create', [
            'user' => $user,
        ]);
    }
676673
public function actionCreate()
    {
        $model = new Event();
        $model->plugin_id = Plugin::EVENTS_CORE;

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect('index');
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }