Generate unique indexes for new styles attachments form

Fixes #3940