How to create a new form with Gii’s Form Generator in Yii 2

In this tutorial I will explain how to create a new form with Gii's Form Generator in Yii 2. The Form Generator of Yii generates a view script file that displays a form to collect input for the specified model class.

With Form Generator you can easily create your form right from your browser. If you want to create a new form, just create a new table in your database, go to Gii and create a model for your table.

Then, go to Form Generator, and enter your wanted name of view file and name of your new created model.

image

Click on the Preview button, and click on the Generate button. Copy the new created action and add it into your Controller.

Now go to http://localhost/(name of your project)/web/index.php?r=name of your controller/and name of your action and you will see the created form.









Leave a Comment