public function value($value) { if (empty($value) and $this->empty) { return array(); } elseif (is_object($value)) { $model = Sprig::factory($this->model); // Assume this is a Database_Result object $value = $value->as_array(NULL, $model->pk()); } else { // Value must always be an array $value = (array) $value; } if ($value) { // Convert objects in array to IDs foreach ($value as $k => $item) { if (is_object($item)) { $value[$k] = $item->{$item->pk()}; } } // Combine the value to make a mirrored array $value = array_combine($value, $value); foreach ($value as $id) { // Convert the value to the proper type $value[$id] = parent::value($id); } } return $value; }
public function set($value) { if ($value instanceof Sprig) { $value = $value->{$value->pk()}; } return parent::set($value); }
public function set($value) { return parent::set((array) $value); }