Variables in a relation condition

I’m doing something wrong here, and/or just not understanding relations. Basically, I have this relation:





			'systemPreferences' => array(

				self::HAS_MANY,

				'CS_Preferences',

				'preferences.login',

				'conditions' => array(

					'or',

					'preferences.login' => $this->login,

					'preferences.login' => '~SYSTEM'

				)

			),

I realized after a little digging that relations must be called before the model is instantiated with data, so the meta data columns is empty and does not contain the login variable. How would I write this then? Or is what I’m trying to do just not possible in a relation?

Hey there!

I just ran into this situation recently and found this solution which has worked!

http://tariffstreet.com/yii/2011/10/adding-conditions-to-yii-model-relations/

HTH

Jake