OSDN Git Service

- added Ethna_ActionForm#setFormDef_PreHelper for dynamis form definition setting.
authormumumu-org <mumumu-org@2ef88817-412d-0410-a32c-8029a115e976>
Sat, 17 Jan 2009 17:42:32 +0000 (17:42 +0000)
committermumumu-org <mumumu-org@2ef88817-412d-0410-a32c-8029a115e976>
Sat, 17 Jan 2009 17:42:32 +0000 (17:42 +0000)
CHANGES
class/Ethna_ActionForm.php
class/Ethna_Controller.php

diff --git a/CHANGES b/CHANGES
index 67afaa1..f76dc04 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -14,6 +14,9 @@
 - フォームヘルパの動作を改善
 -- 1つのテンプレートに 複数 {form} が指定されたときに、submitされたformに対してのみ補正処理が働くように改善 この場合、{form name=...} 属性の指定が必須。
 -- 1つのテンプレートに 複数 {form} が置かれた場合に、それぞれのフォームの配列を区別するようにした
+- フォーム定義を動的に変更するためのAPIを追加
+-- Ethna_ActionForm#setFormDef_PreHelper
+--- Ethna_Backend や Ethna_Session が初期化後に呼ばれる 
 
 *** bug fix
 
index adc0e11..798e90c 100644 (file)
@@ -1227,6 +1227,19 @@ class Ethna_ActionForm
     }
 
     /**
+     *  ユーザが動的にフォーム定義を変更したい場合に
+     *  このメソッドをオーバーライドします。
+     *  $this->backend も初期化済みのため、DBやセッション
+     *  の値に基づいてフォーム定義を変更することができます。
+     *
+     *  @access public 
+     */
+    function setFormDef_PreHelper()
+    {
+        //  TODO: override this method. 
+    }
+
+    /**
      *  ヘルパオブジェクト(アプリケーションオブジェクト)
      *  経由でのフォーム値定義を設定する
      *
index fd3eb6a..a7db244 100644 (file)
@@ -957,18 +957,20 @@ class Ethna_Controller
 
         // オブジェクト生成
         $backend =& $this->getBackend();
+        $session =& $this->getSession();
+        $session->restore();
+
+        // 言語切り替えフックを呼ぶ
+        $this->_setLanguage($this->locale, $this->system_encoding, $this->client_encoding);
 
+        // アクションフォーム初期化
+        // フォーム定義、フォーム値設定
         $form_name = $this->getActionFormName($action_name);
         $this->action_form =& new $form_name($this);
+        $this->action_form->setFormDef_PreHelper();
         $this->action_form->setFormVars();
         $backend->setActionForm($this->action_form);
 
-        // アクションに必要とされる全てのオブジェクトが
-        // 初期化されたあと、言語切り替えフックを呼ぶ
-        $session =& $this->getSession();
-        $session->restore();
-        $this->_setLanguage($this->locale, $this->system_encoding, $this->client_encoding);
-
         // バックエンド処理実行
         $forward_name = $backend->perform($action_name);