I was wondering if there is consensus on whether a widget should ever handle and change post data.
I have something that I would like to use in many places, but it needs to have a form. If I made it a widget, I would still need a subclass of CFormModel to validate it, a widget code file, and a template.
Also, I couldn’t find any examples of other widgets that post data back and save it to the DB, so that makes me think it would be better to just use some actions in the controller with sub templates in the views directory.
I guess I was asking if it was standard to have the widget rely on a formModel object for validation as well. All the examples I could find had just the widget class file and a view, and I was making sure I Wasn’t doing something that would come back to bite me later. Thanks for the feedback!
I guess I was asking if it was standard to have the widget rely on a formModel object for validation as well. All the examples I could find had just the widget class file and a view, and I was making sure I Wasn’t doing something that would come back to bite me later. Thanks for the feedback!
Since I can handle the login in the init() and run() functions, and the display in the renderContent() function, I can make the widgets self-contained in one file in most cases. The thing that feels weird is form validation. I still have to have a separate file with my FormModel object, and I would really like to keep my widget in one file.
I guess I have to choose between a widget with strong form validation and a widget in one file. Is this correct, or can I pass some sort of config array to the CForm constructor that would allow me to specify validation?
Ideally, I would love to be able to do something like: