RelationValidator sets relation return value in the .rules() specified field.
It helps avoid making redundant methods for setting values, returned by STAT-relations, in the AR-fileds. Or you may think up your own use cases.
Current version is always here: https://github.com/pavel-voronin/yii-RelationValidator/.
Clone yii-RelationValidator from github:
cd protected/extensions git clone git://github.com/pavel-voronin/yii-RelationValidator.git
Put next strings in protected/config/main.php:
'import' => array ( 'ext.yii-RelationValidator.RelationValidator' ),
class Post extends CActiveRecord { // ... public function rules ( ) { return array ( array ( 'post_rating', 'RelationValidator', 'relation' => 'post_rating', // relation name from ::relations() 'forceRefresh' => false, // whether to fully reload specified relation 'except' => 'insert' ), ); } public function relations ( ) { return array ( 'post_rating' => array ( self::STAT, 'PostVotes', 'post_id', 'select' => 'SUM(vote)' ) ); } // ... }
Total 2 comments
Voila! :)
P.S.: There was simple russian.
Could you please translate your extension to english? That way, the extension will be available to all community.
Leave a comment
Please login to leave your comment.