Static variable from class as ActiveForm field

Hello Guys,
is it possible to display a static variable from a class as a field (ActiveForm) in the view?

I have a class class CCrossSelling extends ActiveRecord.

class CCrossSelling extends ActiveRecord{
    public $isUsed;
    public $cCrossSellingContainers;

This class contains a variable
public $cCrossSellingContainers;

which holds a list of objects from the class CCrossSellingContainer extends ActiveRecord.

In CCrossSelling there is also a variable called public $isUsed;.
Now I want to disable the rules of all existing CrossSellingContainers if isUsed == true.
My rules in CCrossSellingContainer:

    public function rules()
        return [
            [['title', 'price'], 'required'],
            [['price'], 'number', 'numberPattern' => '/^\s*[-+]?[0-9]*[.,]?[0-9]+([eE][-+]?[0-9]+)?\s*$/'],
            ['description', 'safe'],

I need somethin like this:

    return [
        [..., 'required', 'when' => function ($model) { $model->isUsed == true; }, 'whenClient' => "isNewsletterComponentUsed"],

But I cant check directly on isUsed in this case, because it’s stored in the CCrossSelling object and not in the CCrossSellingContainer.

Is there any way to disable the rules in the given case? Thanks alot!

Hi There,

I think you are complicating the business use case with oops concept. Where exactly you want to remove the validation?

If you want to remove the validation in CCrossSellingContainer class then that particular class should have isUsed as public or private member.

So depending on your use case just assign the value to the same member variable of the class CCrossSellingContainer by referring CCrossSelling’s isUsed.

Nor follow a simple inheritance in order to do better and perfect business logic implementation