Add / Edit Form

Hi,

How do I know do an add / edit form in one view?

i.e.





if(this_is_new_entry) {


// show add form details


} else {


// show edit form details.


}


if(this_is_new_entry) {


// show add form submit button


} else {


// show edit form submit button.


}




Checkout the Gii generated view _form.php.

For instance, you have this conditional statement which is what you asked for in your second question. Use the same test if you need a separate set of input fields. Another nesting level of renderPartial may be an option.




echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');



/Tommy

Thanks, for your help. Sorted now.