gii view code generation

Dear yii framework developers,

I think after generating code from gii still there has some repetitive work for datetime, bool, enum,text, one-to-many, many-to-many relational column. But if gii generate code for those type of table column then it will be more useful for developers. For datetime a calender control can attached with text field, for boolean type column a dropdown list can be added with two text true/false, for enum type a dropdown list can be added with 1,2,3 value,For tex type column a textaria or an opensource text editor like ckeditor or tyniMce code can be generated. For one to many a dropdownlist populated with relative model data can be generated. for many-to-many check list group box can be generated. also from generation time there should an option for generate those fields or flat textbox.

Thanks

Check the giix extension - http://www.yiiframework.com/extension/giix

How about a webpage like Gii to access and modify the config.php file ?

Thanks mdomba for your reply. But actually we want it as a part of Yii v2.0 framework not as an external extension. Also at that extension it is mentioned that is not a fully tested extension and also they have suggested only use the extension for testing purpose not for development. But we aspect a development ready Gii in replace of current version of Gii

Again thanks for your replay.

Idea of adding type-based generation to Gii was there for a long type. It sounds very cool at first but there are problems.

  1. We don’t know what type of input we should generate. For example, it’s not clear if we should generate checkboxes, radios or just a textfield for enum. What’s bad is that it will be very annoying if we’ll generate wrong types all the time and developer will have to change more complex code.

  2. Gii have custom templates support so one can create his own templates with all necessary checks.

  3. Adding CKEditor or TinyMce is definitely a bad idea. It’s up to developer to decide which one to use and if it should be used at all.

I have plans to make my own templates for my projects and I came up with the idea to add the ability to select what type of inputs and filters to generate for the fields at the preview phase. Why? Because that really depends on the situation: at one time I have a small related table and I can render a select box for filter and _form.php. At the other situation I can have a big table (say Users) - so I would generate an text input for filters and hand-craft some sort of picker for the _form.php. And for ENUM fields I, for example, always use the select box - it’s more compact that radio buttons and feels natural.

Dear samdark,

At the end of the post I have mentioned "also from generation time there should an option for generate those fields or flat textbox." . If anyone do not need that they will not generate with those controls. Advanced option may initially collapsed. If someone wish then he will expand advanced option and will check relative control from possible combination of control list. ( I am apologizing for my sentence. But I have just shared my thinking about Yii, Cause I love Yii so much ).

There for Yii developers have done a great job definitely no doubt about it. Not only great job but also they have been removed PHP developers may kind of pain and given them a waya of standard quality programming. Thanks Yii developer team for that.

masum

Yeah, this way it makes sense.

Been generating modules, then models, then CRUD or controllers with Gii for the past week while creating a new version of an application for work based of Yii2 to replace an older 1.1.x version. Gii still can’t generate CRUD for nested modules although it does a nice job of generating nested modules, models and controllers based on paths. For some odd reason, Gii is generating views of multi-word camelCase views with hyphens separating the view file words. However, the generated CRUD fails to recognize the hyphens and they need to be removed before the CRUD code runs debug free.

This is what we are obligated to do–create useful solutions written with minimal amounts of code. There are always problems and for every problem are always numerous solutions. Cannot get much done if you do not keep an open mind and listen to your user base.

The model is already generated before the you attempt to generate the CRUD. Gii already knows what element it is going to assign to each table column based on data type. It should be possible to display a form with the various columns from the model along with drop down lists of possible alternative form elements. Then allow Gii to generate the CRUD based on a temporary file generated from the form selections.

Sure, this is possible. But why not do it right in the first place to open up the possibilities.

Creating a single abstract Editor class or class implemented from an Interface and allowing developers to extend it to create wrappers for the various editors is possible. Look at the Joomla CMF framework as an example. Any number of js-based editors can be wrapped based on their solution. Do a search on the composer package list for ‘editor’. There is at least one Joomla-like solution listed.

Currently we don’t have enough time to implement all these enhancements. Fill these to github and we’ll handle these when more critical issues will be solved. Or submit pull requests. That’s even better.

Are you speaking about automatically adding module entries to the configuration when the module code is generated? That is, a module needs to be declared in config before Gii generates CRUD for a module.

Or are you looking for something more sophisticated that can handle overall config file maintenance. This goes beyond the framework itself and is more of an application maintenance requirement. It probably should be handled using a module with the smarts to change file permissions and write configuration changes in a secure manner. This approach has been used in the past in 1.x extensions for parameters and with some minor tweaking for top level modules and module specific parameters. It involves using a database table with ‘key’ ‘value’ pairs. Anything more sophisticated needs to introduce a category-like hierarchy table to handle various parameter nesting levels as well as nested modules.

Curious about what you really want because I’m working on a solution for the later and will most likely do something to handle the former while working on some Gii templates.

Understand the time constraints and the need to solve more important issues. Have done a lot of volunteer work myself elsewhere.

I experimented with a solution for wrapping textarea using a helper extended from BaseHtml. I could only find two Yii2 editor extensions and need to make sure it works with more editors before posting code.

I just started researching the form element assignment issue and Gii templates. It’s going to require a multi-part form template. Once the model is declared on the existing form, a list of table columns can be dynamically generated for the second part of the form. Maybe, you have some ideas for a better approach (e.g., a wizard-like sequence). The solution is probably going to require a helper to handle the population of dropdown lists for the various data types. Any advice from a user interface perspective would be appreciated.

I’m still not sure about the config issue mentioned above. I believe he was requesting the automatic addition of the module array in the main configuration file when the module code is generated, thus allowing CRUD to be generated after model generation without manually editing the config file. The big problem here is application specific config file naming and the existence of multiple sets of config files. There is also the possibility that the developer may have parted out the module array into a separate config file.