T
T
tigra2015-09-28 12:54:07
JavaScript
tigra, 2015-09-28 12:54:07

How to add a record and update it in one form?

There is a form that adds a record.
When you click on the edit button, the data from the fields is entered into this form.
How to implement record update in the same form?
7decca13d14c4470ab84150a7ff7539c.jpg
af5ea9bcc4a64aafbb12e220c9dd5328.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2015-09-28
@sggr

Create\find model in controller
Pass model to create\update view, depending on action
In create\update view, use echo $this->renderPartial('_form', array('model'=>$model)) passing model into the form view The form view
must contain the form code itself that works with the model + certain simple display logic, depending on whether it is a new entity or an existing one. For example, the name of the button $model->isNewRecord ? 'Create' : 'Save'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question