B
B
Boris Yakushev2016-09-16 19:08:19
Yii
Boris Yakushev, 2016-09-16 19:08:19

Get value passed to yii2 model?

Good evening.
There is a form in which I enter id, this field in the model is called subscription:
e71297c8cf.png
How to get this id in behaviors?

public function behaviors()
{
    return [
        [
            'class' => AttributeBehavior::class,
            'attributes' => [
                ActiveRecord::EVENT_BEFORE_INSERT => [
                    'count',
                ]
            ],
            'value' => Subscription::findOne(вот тут)->count,
        ],
    ];
}

Tried $this->subscription but got an error.
Thanks everyone for the advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2016-09-16
@za4me

We open the documentation and compare what we are doing wrong , I’ll tell you with
a link, but there are doubts that you will find what you need
www.yiiframework.com/doc-2.0/yii-behaviors-attribu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question