Skip to content

Instantly share code, notes, and snippets.

@DrMabuse23
Created September 24, 2014 12:38
Show Gist options
  • Save DrMabuse23/7d2fa133d9de528ec2c3 to your computer and use it in GitHub Desktop.
Save DrMabuse23/7d2fa133d9de528ec2c3 to your computer and use it in GitHub Desktop.
public function actionGetModel()
{
$model = new ContactForm();
$captcha = new Captcha();
$captcha->model = $model;
$captcha->attribute = 'verifyCode';
$cview = $captcha->getView();
$response = new Response();
$response->format = Response::FORMAT_JSON;
// $response->data['message'] = "ContactForm";
$response->content = Json::encode(
[
'attributes' => $model->attributes,
'validation' => $model->activeValidators,
'rules' => $model->rules(),
'labels' => $model->attributeLabels(),
'captcha' => $cview
]
);
$response->setStatusCode(200);
\Yii::$app->end(0, $response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment