unchanged
Title
Code style
Where to put what ------------------Many time,Often, when writing widgets or editingGiiYii code,there can be the doubt ifit is unclear whether or not the code is following the MVCpatter or not.pattern.AHere are a fewsuggestion can helpsuggestions todetectedhelp detect the mostevident error of style.obvious style errors. ### ControllerIn theThe controllerthereshouldbe thecontain code forcollectcollecting user input,retriveretrieving models from the database, and rendering views. In a controller there should never be: -html code (itHTML code: HTML should be in theview)view -sql code (thereSQL code: If needed, SQL shouldnever be, if is needed it should staybe in amodel)model -field name theyField names: Field names should be in theview.view Avoiding embedding field namesallowallows you to change the databasewith minimal effort.easily. ### ViewsIn the views (and only in the views) thereHTML code should only bethe html code.in views.In the view thereViews should notbe:contain: -user input ($_GET, $_POST)User input (e.g. $_GET and $_POST): Input should be collected in models in the controllers, never in views. -sql code: ifSQL: When needed, it isneede, betterbest tocrete functionscreate a function in themodelsmodel Theless php operationfewer PHP operations there are in the views, thebestbetter it is. Instead ofconcatnate 2concatenating two fields, it is better to write a getter method, so you can reuse it in other views. ### ModelsThe models are used for collect user inputs and access to the database.InModels are used for collecting user inputs, and accessing the database. In models there should not be: - User input ($_GET, $_POST): You should write a function that will be called in the controller. - HTML: HTML should be in a view- user input ($_GET, $_POST)you should write a function that will be called in the controller. - html code (it should be in the view)Widgets ------------------ Widgetshashave abehaviorbehaviour similar to controllers. If a widget is supposed to create a lot ofhtml,HTML, it is better to create a view file for it.