Empty repeater field(s) on duplicate

Hello,

I have a repeater form field in a SettingsModel, and the items in this repeater need to be unique, so I have a ‘code’ field (slug preset from ‘title’ field). Now, when I duplicate a record, the ‘code’ field is also duplicated.

Is there a way to empty the ‘code’ and/or ‘title’ field when I duplicate a record?

Or is there perhaps a better way to achieve this?

Thanks in advance!

  • Kevin

Hi @kevin-invato,

You can use the filterFields method in your model to manipulate or clear the value of the code and title fields when a record is duplicated. This will allow you to set those fields to empty or apply any other logic you need for duplication.

Thanks for your reply!

Do you perhaps have a example code? Because when I use the filterFields method, all of the repeater items have empty titles and codes when I open the settings page.

The context seems to be always ‘update’.