From 9643c3c7bb58d0339e577b33ac517354b21e3569 Mon Sep 17 00:00:00 2001
From: Daniel <darthdaniel85@gmail.com>
Date: Mon, 20 Oct 2014 17:44:12 -0500
Subject: Completed tryToUpdateView and tryToUpdateAR.

---
 framework/Web/UI/TPage.php | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

(limited to 'framework/Web')

diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 82e1f0ae..b1f59b3c 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -1277,9 +1277,39 @@ class TPage extends TTemplateControl
          * @param TActiveRecord $arObj
          * @author Daniel Sampedro <darthdaniel85@gmail.com>
          */
-        public function tryToUpdateAR($arObj)
+        public function tryToUpdateAR($arObj, $throwExceptions = false)
         {
-            
+                $objAttrs = get_class_vars(get_class($arObj));
+                foreach (array_keys($objAttrs) as $key)
+                {
+                        try
+                        {
+                                if ($key == "RELATIONS")
+                                {
+                                       break;
+                                } 
+                                $control = $this->{$key};
+                                switch (get_class($control))
+                                {
+                                        default:
+                                        case "TTextBox":
+                                                 $arObj->{$key} = $control->Text;
+                                                break;
+                                        case "TCheckBox":
+                                                $arObj->{$key} = $control->Checked;
+                                                break;
+                                        case "TDatePicker":
+                                                $arObj->{$key} = $control->Date;
+                                                break;
+                                }
+                        } catch (Exception $ex)
+                        {
+                                if ($throwExceptions)
+                                {
+                                        throw $ex;
+                                }
+                        }
+                }
         }
 }
 
-- 
cgit v1.2.3