Sharing view for models in create and edit mode

I am writing a web application using Yii.

I found that most part of my code in create form and edit form are similar.

Surely, the action for edit form and values are different for the forms.

Can I shared the view for them? Many thanks.

If you look at crud generated files, you would see that yii already does something similar by using partial views for forms and reusing them for both create and update functions.

User gii tool to generate code and see Yii will do and follow same for your custom form

Check this files generated by gii tool, you will get understand




Many thanks. It works!