xPDO.newObject
Last updated not available | Page history | Improve this page | Report an issue
xPDO::newObject¶
Creates a new instance of a specified class. All new objects created with this method are transient until xPDOObject::save() is called the first time and is reflected by the xPDOObject::$_new property.
Syntax¶
API Docs: http://api.modxcms.com/xpdo/xPDO.html#newObject
object|null newObject (string $className, [array $fields = array ()])
Example¶
Create a new Box object:
$box = $xpdo->newObject('Box');
Create a new Box object with the width and height already set:
$box = $xpdo->newObject('Box',array(
'width' => 10,
'height' => 4,
));