voshkin
(Voshkinengineer)
January 6, 2017, 10:56am
1
Hi guys. I’ve bumped with next difficulties:
I need to make a custom validation. I’m using ajax and the form events for this. I attach gist with full info. I wonder, why my goddamn code isn’t working.
My js console is empty.
controller.php
public function actionAjaxValidation()
{
\Yii::$app->response->format = Response::FORMAT_JSON;
$result = [];
$model = new SomeModelForm();
$post = \Yii::$app->request->post();
$model->load($post);
$result['errors'] = ActiveForm::validate($model);
This file has been truncated. show original
order of script files in the layout
<script src="/assets/1ac78ba4/jquery.js"></script>
<script src="/js/someModelForm.js"></script>
<script src="/assets/bfc0238/yii.js"></script>
<script src="/assets/bfc0238/yii.activeForm.js"></script>
<script src="/assets/70a7529/js/bootstrap.js"></script>
<script type="text/javascript">jQuery(document).ready(function () {
jQuery('#someModelForm').yiiActiveForm([], []);
});</script>
someModelForm.js
$(function () {
var $someForm = $(this).find('form'),
$submitBtn = $someForm.find('[type=submit]'),
$formData = new FormData($someForm[0]);
$someForm
.on('beforeValidate', function () {
$.ajax({
url: $someForm.prop('action'),
data: $formData,
This file has been truncated. show original
There are more than three files. show original