GridView has a core feature of being able to simplify filter rows just by putting an additional row below the header row.
Filters are mainly text input but in general they can be any type of control and we can customize them as much as we want.
Filters can be activated by filling out the GridView widget property filterModel
with an instance of the model class and automatically a new row will be created below the header, containing working text inputs.
Filter text inputs have a name attribute filled with the model class name, which includes the field name. In this way, we will pass data to a controller, including everything in a single array; a variable that can easily be used to populate a search model massively.
Note
Automatic text input filters are created only for attributes that belong to at least one rule in the rules()
method of ActiveDataProvider
; otherwise it is enough that attributes belong to the safe
validator.
Let's create an example with the reservations grid.
We...