Skip to content

Model Configuration

beforeCreate()

beforeCreate() — returns void

Available in: model Category: Callback Functions

Registers method(s) that should be called before a new object is created.

NameTypeRequiredDefaultDescription
methodsstringno—Method name or list of method names that should be called when this callback event occurs in an object’s life cycle (can also be called with the method argument).
// 1. Register a single callback method to run before a new object is created
// Defined inside the model's config() function
beforeCreate("setDefaults");

// 2. Register multiple callback methods to run in sequence before creation
beforeCreate("generateSlug,stampCreatedBy");

// 3. Register callbacks using the named argument
beforeCreate(methods="generateToken,normalizeEmail");