multi model forms in yii

后端 未结 4 1682
故里飘歌
故里飘歌 2020-12-13 10:32

How to create a multi-model form in Yii? I searched the entire documentation of Yii, but got no interesting results. Can some one give me some direction or thoughts about th

4条回答
  •  生来不讨喜
    2020-12-13 11:37

    You don`t need a multi-model. The right use of the MVC pattern requires a Model that reflects your UI.

    To solve it, you'll have to use a CFormModel instead of an ActiveRecord to pass the data from View to Controller. Then inside your Controller you`ll parse the model, the CFormModel one, and use the ActiveRecord classes (more than one) to save in database.

    Forms Overview and Form Model chapters in Yii Definitive Guide contains some details and samples.

提交回复
热议问题