Comparing
#11 with
#12
Revision #12 was created by
Maurizio Domba Cerin on Oct 18, 2011, 8:44:22 AM.
more fixes
Content
[...]
For example if you tried to get a user via active record it can be null if it does not exist, you need to check it...
<hr/>
### Why Form / ActiveForm
is not doing ajax validation ?
#### Answer:[...]
```php
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'
top-websites-cr-form
-id',
'enableAjaxValidation'=>true,
'clientOptions' => array(
'validateOnSubmit'=>true,
'validateOnChange'=>true,
'validateOnType'=>false,
),
)); ?>
```[...]
If you create your own form, and trying to do this... better create CRUD with gii, and see how it is done there!
yYou need to echo the validation results if this is an ajax request!
viaBy using:
```php
echo CActiveForm::validate($model);
```
<hr/>
### How to use find
() / findByAttributes
() etc.
#### Answer:[...]
```
oOther way is
to specify [CDbCriteria](http://www.yiiframework.com/doc/api/1.1/CDbCriteria "http://www.yiiframework.com/doc/api/1.1/CDbCriteria")
.
<hr/>[...]
```php
Yii::app()->db->commandBuilder->createUpdateCommand(
'{{table}}',
array(
'counter' => new CDbExpression( 'counter + :counter' , array(':counter'=>1))
),
new CDbCriteria(array(
),
new CDbCriteria(
array(
"condition" => "id = :id" ,
"params" => array(
"id"=>1
)
)
)
)
)
)->execute();
```