Design Question: Separate Or Common Views
Posted 29 April 2013 - 07:05 AM
So, what is the best practice in such situation? Keep it following DRY rule and move parts that repeats (with a little bit customization) to admin module as partial views, form which generic views from other modules will share them using renderPartial. Or to keep maximum flexibility, for the price of repeated code.
Posted 30 April 2013 - 02:46 AM
if the header and footer are same across views, you could use CContentDecorator widget (http://www.yiiframew...ontentDecorator) and put common parts in separate view used by decorator. As for field definitions I would stick to separate view for every model/action because it is easier to customize them Changing that will be also move from scaffolding to model-driven development and I had many bad experience with such approach - there is always someone who says "this field must be next to that one in same line" and model-driven code just does not support such case
Posted 01 May 2013 - 04:59 AM
No, way -- fields always remain per-view. I don't have that much bad experience as you, but I also see, that this is wrong (dead) path. So I was only asking about form's header and footers.
I haven't got much experience with decorators, so thanks for the tip. I was also thinking about using simple clips here. But the general solution, I'll follow is not a matter of question here. I was asking the design question, so whether to do this or not. Not, how to do this. And it seems, that you support the idea of moving the same or nearly the same parts to common repository and re-use them in separate views.
Thanks and have a great long weekend! :]