From 66f612cb80028de2f03f80fa13a84fa8d89c2b42 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Sat, 13 Mar 2010 15:11:02 +0200 Subject: [PATCH] Attach the Sprig object to the Field object for cross referencing --- classes/sprig/core.php | 3 +++ classes/sprig/field/core.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/classes/sprig/core.php b/classes/sprig/core.php index f86b858..32003ce 100644 --- a/classes/sprig/core.php +++ b/classes/sprig/core.php @@ -144,6 +144,9 @@ protected function __construct() foreach ($this->_fields as $name => $field) { + // Assign this model to the field + $field->object = $this; + if ($field instanceof Sprig_Field_ForeignKey AND ! $field->model) { if ($field instanceof Sprig_Field_HasMany) diff --git a/classes/sprig/field/core.php b/classes/sprig/field/core.php index 622cffc..c515f27 100644 --- a/classes/sprig/field/core.php +++ b/classes/sprig/field/core.php @@ -87,6 +87,11 @@ abstract class Sprig_Field_Core { */ public $callbacks = array(); + /** + * @var object {@link Sprig} model parent + */ + public $object; + public function __construct(array $options = NULL) { if ( ! empty($options))