Hi,
This is a technical question. I've been handed down a custom CA plugin which needs to be finished. The plugin is automatically adding a default value to an object field after the object is saved in the object editor. The field itself is repeating, so it can contain multiple values. The problem is that the original logic is removing all other values in the field and inserts a default value, while it should leave already added values alone. So: it should perform be an "update" rather then "replace" action.
The field itself is a metadata element which was manually added via the metadata element administration interface and the Object editor UI interface.
The plugin logic does something like this:
public function hookAfterBundleUpdate($pa_data) {
$t_object = $pa_data['instance'];
$t_object->removeAttributes('myCustomFieldCode');
$t_object->AddAttribute(array('key' => 'value'), 'myCustomFieldCode');
$t_object->update();
}
So. It removes everything and then adds a single attribute. So I was wondering:
I've toyed a bit with the getAttribytesByElement() method to check if the field already contains values. But when I pass the string 'myCustomFieldCode' as an argument, I just get an empty array. So, how do I get the values of a metadata element instance?
Is there an update method which does an update/merge action of values instead of an replace action?
Is there clear API documentation somewhere beyond the high-level summary in the wiki?
Thanks!!