From 9db6e012559ae7bdb46a9519c360bb936173f200 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Wed, 5 Sep 2007 01:43:17 +0000
Subject: typos in blog tutorial. fixed empty result in active record
relations. fixed keeping of post data in scaffold edit view when using
renderer.
---
demos/blog-tutorial/protected/pages/Day4/CreateReadPost.page | 2 +-
demos/blog-tutorial/protected/pages/Day4/id/CreateReadPost.page | 2 +-
framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php | 3 ++-
framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php | 8 +++++++-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/demos/blog-tutorial/protected/pages/Day4/CreateReadPost.page b/demos/blog-tutorial/protected/pages/Day4/CreateReadPost.page
index d9b66d33..2b21023d 100644
--- a/demos/blog-tutorial/protected/pages/Day4/CreateReadPost.page
+++ b/demos/blog-tutorial/protected/pages/Day4/CreateReadPost.page
@@ -23,7 +23,7 @@ The ReadPost page template is very similar to the PostRenderer
<com:TControl Visible="<%= $this->canEdit() %>">
- Edit |
+ Edit |
<com:TLinkButton Text="Delete"
OnClick="deletePost"
Attributes.onclick="javascript:if(!confirm('Are you sure?')) return false;" />
diff --git a/demos/blog-tutorial/protected/pages/Day4/id/CreateReadPost.page b/demos/blog-tutorial/protected/pages/Day4/id/CreateReadPost.page
index 83c059e7..9aeaed7b 100644
--- a/demos/blog-tutorial/protected/pages/Day4/id/CreateReadPost.page
+++ b/demos/blog-tutorial/protected/pages/Day4/id/CreateReadPost.page
@@ -23,7 +23,7 @@ Template halaman ReadPost sangat mirip dengan template PostRenderer
<com:TControl Visible="<%= $this->canEdit() %>">
- Edit |
+ Edit |
<com:TLinkButton Text="Delete"
OnClick="deletePost"
Attributes.onclick="javascript:if(!confirm('Are you sure?')) return false;" />
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
index 60afef89..de6e5331 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
@@ -64,7 +64,8 @@ abstract class TActiveRecordRelation
static $stack=array();
$results = call_user_func_array(array($this->getSourceRecord(),$method),$args);
- if(is_array($results) || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
+ $validArray = is_array($results) && count($results) > 0;
+ if($validArray || $results instanceof ArrayAccess || $results instanceof TActiveRecord)
{
$this->collectForeignObjects($results);
while($obj = array_pop($stack))
diff --git a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
index 0550864b..ea9b2df5 100644
--- a/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
+++ b/framework/Data/ActiveRecord/Scaffold/TScaffoldEditView.php
@@ -214,6 +214,12 @@ class TScaffoldEditView extends TScaffoldBase
$record->save();
return true;
}
+ else if($this->_editRenderer!==null)
+ {
+ //preserve the form data.
+ $this->_editRenderer->updateRecord($this->getCurrentRecord());
+ }
+
return false;
}
@@ -300,5 +306,5 @@ interface IScaffoldEditRenderer extends IDataRenderer
*/
public function updateRecord($record);
}
-
+
?>
\ No newline at end of file
--
cgit v1.2.3