OSDN Git Service

- array form counter is now reset in every {form}.
authormumumu-org <mumumu-org@2ef88817-412d-0410-a32c-8029a115e976>
Fri, 2 Jan 2009 10:38:08 +0000 (10:38 +0000)
committermumumu-org <mumumu-org@2ef88817-412d-0410-a32c-8029a115e976>
Fri, 2 Jan 2009 10:38:08 +0000 (10:38 +0000)
CHANGES
class/Ethna_SmartyPlugin.php
class/Ethna_ViewClass.php

diff --git a/CHANGES b/CHANGES
index a2948a6..1432e68 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,7 @@
 - フィルタを一貫してプラグインから取得するように変更
 - フォームヘルパの動作を改善
 -- 1つのテンプレートに 複数 {form} が指定されたときに、submitされたformに対してのみ補正処理が働くように改善 この場合、{form name=...} 属性の指定が必須。
+-- 1つのテンプレートに 複数 {form} が置かれた場合に、それぞれのフォームの配列を区別するようにした
 
 *** bug fix
 
index a435e66..6b75809 100644 (file)
@@ -789,16 +789,20 @@ function smarty_block_form($params, $content, &$smarty, &$repeat)
 {
     if ($repeat) {
         // {form}: ブロック内部に進む前の処理
+        
+        // 配列指定のフォームヘルパ用カウンタをリセットする
+        $c =& Ethna_Controller::getInstance();
+        $view =& $c->getView();
+        $view->resetFormCounter();
 
         // {form default=... }
         if (isset($params['default']) === false) {
             // 指定なしのときは $form を使う
             // 1テンプレートに複数 {form} を指定する場合は、
             // default を指定することが必要
-            $c =& Ethna_Controller::getInstance();
             $af =& $c->getActionForm();
 
-            // c.f. http://smarty.php.net/manual/en/plugins.block.functions.php
+            // c.f. http://smarty.net/manual/en/plugins.block.functions.php
             $smarty->_tag_stack[count($smarty->_tag_stack)-1][1]['default']
                 =& $af->getArray(false);
         }
@@ -823,7 +827,7 @@ function smarty_block_form($params, $content, &$smarty, &$repeat)
             return null;
         }
 
-        // ethna_action
+        // {form ethna_action=... }
         if (isset($params['ethna_action'])) {
             $ethna_action = $params['ethna_action'];
             unset($params['ethna_action']);
@@ -833,7 +837,7 @@ function smarty_block_form($params, $content, &$smarty, &$repeat)
             $content = $hidden . $content;
         }
 
-        //  name
+        //  {form name=... }
         //  指定された場合は、submitされた {form}を識別する
         //  id をhiddenタグで指定する
         $name = $params['name'];
index 74a3869..b6970f0 100644 (file)
@@ -68,6 +68,9 @@ class Ethna_ViewClass
     /** @var    string  遷移先テンプレートファイル名 */
     var $forward_path;
 
+    /** @var    boolean  配列フォームを呼んだカウンタをリセットするか否か */
+    var $reset_counter = false;
+
     /**#@-*/
 
     // {{{ Ethna_ViewClass
@@ -141,6 +144,7 @@ class Ethna_ViewClass
     /**
      *  helperアクションフォームオブジェクトを設定する
      *
+     *  @param  string $action アクション名
      *  @access public
      */
     function addActionFormHelper($action)
@@ -230,6 +234,18 @@ class Ethna_ViewClass
     }
     // }}}
 
+    // {{{ resetFormCounter
+    /**
+     *  フォームヘルパ用、内部フォームカウンタをリセットする
+     *
+     *  @access public
+     */
+    function resetFormCounter()
+    {
+        $this->reset_counter = true;
+    }
+    // }}}
+
     // {{{ getFormName
     /**
      *  指定されたフォーム項目に対応するフォーム名(w/ レンダリング)を取得する
@@ -294,6 +310,11 @@ class Ethna_ViewClass
         // 配列フォームが何回呼ばれたかを保存するカウンタ
         if (isset($def['type']) && is_array($def['type'])) {
             static $form_counter = array();
+            if ($this->reset_counter) {
+                $form_counter = array();
+                $this->reset_counter = false;
+            }
+
             if (isset($form_counter[$action]) === false) {
                 $form_counter[$action] = array();
             }