Created
December 30, 2014 21:21
-
-
Save dedikisme/b47868b75dbac8fe5703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//class Controller | |
public function actionContact() | |
{ | |
$model = new DynamicModel([ | |
'name', 'body' | |
]); | |
$model->addRule(['name', 'body'], 'required') | |
->addRule(['name'],'unique'); | |
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |
echo json_encode($model->attributes); | |
exit(); | |
return $this->refresh(); | |
} | |
return $this->render('contact', ['model' => $model]); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment