$comments_count = $subQuery->select('comments.deadline_id ')
->where(['comments.deadline_id' => 'deadline.id'])
->from('comments')
->count();
for($i =0; $i< 10; $i++){
$form->field($model, 'checkboxList[]')->checkboxList($items); ?>
}
$categories = Category::find()->indexBy('id')->orderBy('id')->all();
$items = ArrayHelper::map($categories,'id','title');
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'checkboxList')->checkboxList($items); ?>
<?php ActiveForm::end(); ?>
$form = ActiveForm::begin([
'id' => 'form-input-example',
'options' => [
'onsubmit' => 'sendAjax(this, myAction)'
],
]);
...
var myAction = function (response) {
//Делаем то, что нам нужно с ответом
console.log(response);
}
function sendAjax(form, callback) {
$.ajax({
method: 'post',
url: '/test',
dataType: 'json',
data: $(form).serialize()
}).done(function (response) {
callback(response);
})
//Возвращаем false чтобы форма не отправилась
return false;
}
public function login()
{
if (!$this->validate()) {
return false;
}
$attributes = [
'email' => $this->username,
'active' => true
];
/* @var User $user */
if (($user = User::findOne($attributes)) && User::validatePassword($user, $this->password)) {
return \Yii::$app->user->login($user, $this->rememberMe ? self::$timeout : 0);
}
$this->addError('username', \Yii::t('models/LoginForm', 'Wrong E-Mail or password'));
return false;
}