Author: Russ
Date: 2010-03-04 19:11:31 +0100 (Thu, 04 Mar 2010)
New Revision: 28382

Modified:
   plugins/sfDoctrinePlugin/branches/1.3-2.0/lib/form/sfFormDoctrine.class.php
Log:
[1.4][sfDoctrine2Plugin] When setting defaults, use getters where available


Modified: 
plugins/sfDoctrinePlugin/branches/1.3-2.0/lib/form/sfFormDoctrine.class.php
===================================================================
--- plugins/sfDoctrinePlugin/branches/1.3-2.0/lib/form/sfFormDoctrine.class.php 
2010-03-04 17:33:31 UTC (rev 28381)
+++ plugins/sfDoctrinePlugin/branches/1.3-2.0/lib/form/sfFormDoctrine.class.php 
2010-03-04 18:11:31 UTC (rev 28382)
@@ -488,6 +488,7 @@
   {
     // update defaults for the main object
     $objdefault = $this->convertObjectToArray();
+
     if ($this->isNew())
     {
       $this->setDefaults(array_merge($objdefault, $this->getDefaults()));
@@ -526,8 +527,19 @@
   {
     $md = 
$this->em->getMetadataFactory()->getMetadataFor($this->getModelName());
     $values = $md->getColumnValues($this->getObject(), 
array_keys($md->fieldNames));
+    $valueArray = array_combine($md->fieldNames, $values);
+    $obj = $this->getObject();
 
-    return array_combine($md->fieldNames, $values);
+    foreach($valueArray as $key => $value)
+    {
+      $getMethod = "get".$key;
+      if (method_exists($obj, $getMethod) && is_callable(array($obj, 
$getMethod)))
+      {
+        $valueArray[$key] = call_user_func(array($obj, $getMethod));
+      }
+    }
+
+    return $valueArray;
   }
 
   /**

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to