SuiteCRM MVC, what is the role of controllers?

So first post on suitecrm.

I had to create a new module that had a dropdown field (populated from another db table). I didn’t want to create a dropdown field so I used the textfield as backend storage and replaced the html control in editviewdef.php. The blank html dropdown was shown.

The next problem was to populate the data. The modules\AOS_Invoices\views\view.edit.php has a method called populateInvoiceTemplates which does something similar so I used it as an example and the data was shown.

Everything is working as expected but my question is, where do controllers fit into all this? Surly the view should not be doing database calls?

@asingh

Welcome to the community!

Yes. You are right, but thevalue of the field for the record does not change in the view. You can change the value in bean. The dropdown is not a value of field. It is form only and it can be compared a radio button. The dropdown is a part of form and you want to make it dynamic. And it should do in the view.

Hi,

Thanks.

Actually thinking about this, the \view.edit.php is kind of like a mini controller so I think its acceptable that it can do db queries. If it had html and php mixed then that would be bad.

So far it has been pretty straight forward to extend things. Thanks for a great product.