From 7fa1200b5e589a47884aa4d62630ce9099fccee1 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 30 Jan 2007 11:36:13 +0000 Subject: Add basic Scaffold view for Active Record --- demos/quickstart/protected/controls/TopicList.tpl | 1 + .../pages/Database/Samples/Scaffold/Home.page | 7 ++ .../pages/Database/Samples/Scaffold/Home.php | 33 +++++++ .../pages/Database/Samples/Scaffold/sqlite.db | Bin 0 -> 4096 bytes .../protected/pages/Database/Samples/config.xml | 5 ++ .../protected/pages/Database/Scaffold.page | 99 +++++++++++++++++++++ 6 files changed, 145 insertions(+) create mode 100644 demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page create mode 100644 demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php create mode 100644 demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db create mode 100644 demos/quickstart/protected/pages/Database/Samples/config.xml create mode 100644 demos/quickstart/protected/pages/Database/Scaffold.page (limited to 'demos/quickstart/protected') diff --git a/demos/quickstart/protected/controls/TopicList.tpl b/demos/quickstart/protected/controls/TopicList.tpl index 698cbeea..8d68c2e2 100644 --- a/demos/quickstart/protected/controls/TopicList.tpl +++ b/demos/quickstart/protected/controls/TopicList.tpl @@ -72,6 +72,7 @@ diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page new file mode 100644 index 00000000..21f508f7 --- /dev/null +++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.page @@ -0,0 +1,7 @@ + + +

Active Record Scaffold Example

+ + + +
diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php new file mode 100644 index 00000000..9bfe3f6d --- /dev/null +++ b/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db b/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db new file mode 100644 index 00000000..65d77a66 Binary files /dev/null and b/demos/quickstart/protected/pages/Database/Samples/Scaffold/sqlite.db differ diff --git a/demos/quickstart/protected/pages/Database/Samples/config.xml b/demos/quickstart/protected/pages/Database/Samples/config.xml new file mode 100644 index 00000000..51da9ed0 --- /dev/null +++ b/demos/quickstart/protected/pages/Database/Samples/config.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Database/Scaffold.page b/demos/quickstart/protected/pages/Database/Scaffold.page new file mode 100644 index 00000000..36a0ec21 --- /dev/null +++ b/demos/quickstart/protected/pages/Database/Scaffold.page @@ -0,0 +1,99 @@ + + +

Active Record Scaffold Views

+

Active Record classes can be used together with + +and + +( +links both TScaffoldListView and TScaffoldEditView) to create +simple Create/Read/Update/Delete (CRUD) web applications.

+ +

The scaffold views are intended to assist in prototyping web application, +they are not designed to be as customiziable as more complex components such as +TDataGrid. The scaffold views provide +the following builtin functionality: +

+ + + +

Scaffold views are dependent on Active Records and currently supports +the following databases: Mysql, Sqlite and Postgres SQL. Support for other databases +can be considered when there are sufficient demand.

+ +

Setting up a Scaffold View

+

To use the scaffold view, we first define an Active Record +class that represents a table or view in the database. Consider the following +Active Record class that corresponds to the users +table as defined in the Active Record quickstart page. +

+ + +class UserRecord extends TActiveRecord +{ + public $username; + public $email; + + public static $_tablename='users'; +} + + +

The scaffold view classes are in the System.Data.ActiveRecord.Scaffold.* +namespace. +This namespace can be "imported" in the +Application Configuration +using the application.xml file or through the php code using the Prado::using() +method. The simplest way to provide CRUD functional is to use the + +where the RecordClass property value equals to an Active Record +class name. +

+ + +<com:TScaffoldView RecordClass="UserRecord" /> + + +

Todo...

+ +

Other views... list view

+ + +<com:TScaffoldListView RecordClass="UserRecord" /> + + +

edit view...

+ +<com:TScaffoldEditView RecordPk="user1" RecordClass="UserRecord" /> + + +

Combining list + edit views

+ + +<com:TScaffoldEditView ID="edit_view" RecordClass="UserRecord" /> +<com:TScaffoldListView EditViewID="edit_view" RecordClass="UserRecord" /> + + +

custom list view...

+ +<com:TScaffoldView RecordClass="UserRecord" > + <prop:ListView.List.ItemTemplate> + <%# $this->DataItem->username %> + <com:TLinkButton Text="Edit" CommandName="edit" /> + </prop:ListView.List.ItemTemplate> +</com:TScaffoldView/> + +

To be completed...

+ +

Address book example...

+ + + +
$Id$
\ No newline at end of file -- cgit v1.2.3