modResource.set
Last updated not available | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodResource::set¶
Sets a field value by key or name. The override intercepts the alias key and runs the value through cleanAlias() first, so a stored alias is always URL-safe. Every other key goes to the parent implementation unchanged.
The return value is true only when the stored value actually changed. Assigning an identical value gives false; so does naming a field that does not exist, which is also logged as an error.
Syntax¶
boolean set ($k [, $v = null [, string $vType = '']])
-
$k(string) field key or name -
$v(mixed) value to store, by defaultnull -
$vType(string|callable) format of the value or a callable replacing the default assignment, by default''
Example¶
$resource = $modx->getObject('modResource', array('id' => 5));
$resource->set('alias', 'Hello World');
$resource->save();
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










