Skip to Content

Quick Duplicate

QuickDuplicate opens a confirmation/edit modal for duplicating an entity. The user can optionally modify fields before confirming.


Import

import { QuickDuplicate } from "@phpcreation/frontend-crud-react-nextjs-bundle/components/QuickDuplicate";

Usage

import { QuickDuplicate } from "..."; <QuickDuplicate open={open} onOpenChange={setOpen} entity={entity} entityConfig={entityConfig} formFields={duplicateFormFields} onSuccess={(newEntity) => { setOpen(false); router.push(`/entities/${newEntity.id}`); }} />

Props

PropTypeDescription
openbooleanModal open state
onOpenChange(open: boolean) => voidOpen state handler
entityEntitySource entity to duplicate
entityConfigEntityConfigEntity configuration
formFieldsFieldConfig[]Fields shown for override before duplicating
onSuccess(newEntity: Entity) => voidCalled after duplication

Duplication POSTs to the entity API with the copied field values. Unique fields (e.g., name) are typically pre-cleared for the user to fill in.


Last updated on