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/.
Requirements ¶
- Yii Framework (any version)
Install ¶
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'
),
Usage ¶
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)' )
);
}
// ...
}
Changelog ¶
version 1.0 ¶
- Initial version. Works great.
In english, please
Could you please translate your extension to english?
That way, the extension will be available to all community.
English version
Voila! :)
P.S.: There was simple russian.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.