public function unrelate($name, $value)
{
if (!isset($this->_fields[$name]) or !$this->_fields[$name] instanceof Sprig_Field_HasMany) {
throw new Sprig_Exception('Unknown relationship: :name', array(':name' => $name));
}
$values = array();
if (is_object($value)) {
$values[$value->{$value->pk()}] = $value->{$value->pk()};
} elseif (is_numeric($value)) {
$values[$value] = $value;
} elseif (is_array($value)) {
$values = $value;
} else {
throw new Sprig_Exception('Invalid data type: :value', array(':value' => $value));
}
// Make sure the field is accessed to load it's values
$this->{$name};
$original = $this->_original[$name];
foreach ($values as $value) {
unset($original[$value]);
}
$this->{$name} = $original;
return $this;
}