0

A model fields and B model fields in same form

Ex:

public static function tableName()
{
    return 'a';
}

public function rules()
{
    return [
        [['id','b_id'], 'id'],
    ];
}
public function beforeSave($insert) 
{
    //I want to save b model here
}

I cant access B model attributes in beforeSave()

Yasar Arafath
  • 605
  • 1
  • 9
  • 30
  • 1
    If you need only save the model b before model a you can do in a simple way in controller . could you explain me why you are trying to save the model b in beforeSave .of the model A ..? – ScaisEdge Oct 04 '16 at 13:36
  • I want to use REST in my app so i need all transaction in model – Yasar Arafath Oct 04 '16 at 15:35
  • 1
    The fact that you want to use REST does not imply that you should use .. BeforeSave () .. even REST uses a controller and action .. anyway .. if tiy need model B in beforeSave() of modelA you can or passthe modelB as a parameter or add a var in modelA with contain modelB ref – ScaisEdge Oct 04 '16 at 15:48

0 Answers0