The Difference Between Model And Dataprovider?

I am trying to get Krajee’s TabularForm working but I am misunderstanding the relationship with dataProvider and model. (I think)

demos.krajee.com/builder-details

can someone explain the differences/background of the two?

Thanks

Stuart

DP is just another layer of abstraction over data.

It’s something that implements dataprovider interface, so it can sort and paginate some data.

For example, ActiveDataProvider provides ActiveRecord data, ArrayDataProvider works with common arrays, and SqlDataProvider uses SQL queries to get results.

Explaining, in layman’s terms when you are reading/writing to DB:

[list=1]

[*]You use a model for a single row read and write to the database table. The FormBuilder widget in my extension therefore uses a model.

[*]When you need to update a batch of records/rows to the same database table - you need basically an array/list of models. The Yii 2.0 ActiveDataProvider provides you a method to retrieve a list of records/rows using ActiveQuery. My TabularForm extension therefore uses data generated by Yii’s brilliant dataProvider to in turn generate a tabular list of inputs that can return an array of models. The dataProvider also enables you to sort and paginate data - hence you can manage large sets of data easily.

The TabularForm typically needs to be used in master detail kind of scenarios. For example, display/edit single customer record using a model & FormBuilder, and display/edit multiple addresses/contacts for the customer using a TabularForm.

[/list]