It works, but I need to know if this is good practices knowing that the widget always needs a model to work, which means dependency on an application resource.
Is that widget helping you to encapsulate dynamics (js scripts, css) specific for that model making your view cleaner? Have you seen zii widgets? They are dependent on data providers and that doesn’t mean they follow wrong practices. They automate certain tasks and encapsulate css and js. If you are just rendering HTML and that is not used along other sections of the project, then… I don’t even think is useful…
I appreciate your reply. The widget is just rendering HTML but it is used a lot in other project sections. The solution I will try to implement is to make the widget independent and show/remove HTML fields according to the parameters that the widget will accept. This way, I ensure it doesn’t need a model to run and will only show the HTML code requested.
Thanks for your help. I ended up doing as you said: Internally defined the model for the widget to use instead of passing it as a parameter. The widget depends on a model, but the views are a lot simpler when I implement it, plus I don’t have to write the same code over and over.