K
K
Konstantin2020-12-04 12:10:17
Yii
Konstantin, 2020-12-04 12:10:17

How to make an ajax request so that the virtual properties of the model come in response?

I make a get request on the rest controller. I get models, but models have properties created via get of type getOfffers. How to make models have an offers property when requested? I thought somehow through extraFields, but it didn't help. Tell me please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Glebov, 2020-12-04
@small_jedi

In ActiveRecord

public function fields()
    {
        $fields = parent::fields();
        $fields = array_merge($fields, [           
            'offers',         
        ]);

        unset(
            $fields['name'],//что то удалить
        );

        return $fields;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question