Hi everyone,
I am a bit confused about using FormModel and AR.
The definition for both of them are very clear when I read them.
When I am ready to get my hands dirty,
I realize that I need to use both model when I am dealing with a single database table.
For example, I have a table call ‘user’ and I have created an AR model of it.
I have also used Yii shell to create the CRUD controller and view of the table.
Creation of user is straightforward, fill in the form, hit enter,
AR model populated and it is saved into the table.
The confusion comes when I want to implement a login view.
I have to create a FormModel because FormModel are meant for collecting user’s input.
Why can’t I use the AR Model for collecting user’s input?
With that in mind, I set out to experiment.
I can use the AR model to collect data from the browser.
I decided to experiment with FormModel.
I can use FormModel to contain the data from the database and send it to the view.
But the codes are more complicated than using AR model.
I prefer using a single model class for interaction with browser and backend.
I think in CakePHP, it uses a single model class.
The last thing I want to do is created a lot of model classes.
Anyone can advise on this.