Searh Model without using GridVIew

Hello everyone,

There is a serch form on the mainpage of a realestate agency. The data about objects is stored in the table "realty" that uses relations. For example, there are related tables category (residential, commercial, land plots), deal (buy, sell, rent), object_type (apartment, house, office).

Then different categories have different properties and and there are three bootstrap tabs in the search form: residential, commercial, land plots. Under each tab there are selects and input fields that are specific for the choosen tab.

In the most cases, the examples of using Search model are given within a gridview.

Is it possible to adapt Search model logic so that it could return the array of results from the table ‘realty’ based on the values indicated in the search form on the mainpage ?

Yes, search model can be used without gridview.

Model is to get/set data (and asure it’s integrity). Model just returns data. Model does not know anything about the viewing of the data.

Actually, if not using any modules or widgets, the search is the action(s) of some controller. These actions prepare the conditions and ask model(s) to get some data which qualifies the conditions. There is nothing about the view of data here.

And when you get data from model(s), then you (controller and action) decide how to display it. For example, you may use the same model, the same controller, the same action to get data (search results), but display it differently: JSON for autocomplete and HTML for search results page.

This is the main benefit of the MVC pattern. You just need to implement it right.