Save As New

Hi, I would like to insert a button like "Save as new" in my form. I mean, you can "Save" button and update record or, using "Save as new", create a new record based on values in the form (of course with validation!). The problem is that $model->save understands automagically if a record has to be inserted or updated in the table. So is there a way to force "Create" record even if we are in Update action?

Don’t know if I’m clear, I hope I am :)

Ciao

Danilo


if($form->submitted('save-as-new')){

  $arModel->setIsNewRecord(true);

  $arModel->setPrimaryKey(null);

}

$arModel->save();

It worked with if($_POST[‘save-as-new’]). Thanks!

P.S. I’ve added 1 point to your reputation, but of course I didn’t it to make you weaker :P