Model Object
changedFrom()
Signature
Section titled “Signature”changedFrom() — returns string
Available in: model
Category: Change Functions
Description
Section titled “Description”Returns the previous value of a property that has changed. Returns an empty string if no previous value exists. CFWheels will keep a note of the previous property value until the object is saved to the database.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Name of property to get the previous value for. |
Examples
Section titled “Examples”// Get a member object and change the `email` property on it
member = model("member").findByKey(params.memberId);
member.email = params.newEmail;
// Get the previous value (what the `email` property was before it was changed)
oldValue = member.changedFrom("email");
// The above can also be done using a dynamic function like this
oldValue = member.emailChangedFrom();