Miscellaneous
toggle()
Signature
Section titled “Signature”toggle() — returns any
Description
Section titled “Description”Assigns to the property specified the opposite of the property’s current boolean value. Throws an error if the property cannot be converted to a boolean value. Returns this object if save called internally is false.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
save | boolean | yes | true | Argument to decide whether save the property after it has been toggled. Defaults to true. |
Examples
Section titled “Examples”toggle([ save ]) <!--- Get an object, and toggle a boolean property --->
<cfset user = model("user").findByKey(58)>
<cfset isSuccess = user.toggle("isActive")><!--- returns whether the object was saved properly --->
<!--- You can also use a dynamic helper for this --->
<cfset isSuccess = user.toggleIsActive()>