[eluser]OverZealous[/eluser]
I don't recommend performing any logic like that inside a validation rule. You could easily get caught in an infinite loop.
However, why don't you do something like this:
Code:
class Whatever extends DataMapper {
...
function save($object = '', $related_field = '') {
// perform logic here
// if necessary, add a new object to the $object array
if(is_array($object)) {
$object[] = $new_object;
} else if(!empty($object)) {
$object = array($object, $new_object);
} else {
$object = $new_object;
}
return parent::save($object, $related_field);
}
}
The only catch is you always need to save it from the Whatever object, but that should be a rather easy-to-enforce situation.