yii-relationvalidator RelationValidator sets relation return value in the .rules() specified field.

  1. Requirements
  2. Install
  3. Usage
  4. Changelog

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.
1 0
6 followers
0 downloads
Yii Version: 1.1
License: MIT
Category: Validation
Developed by: Pavel Voronin
Created on: Jan 16, 2013
Last updated: 7 years ago

Related Extensions