]> git.andy128k.dev Git - ipf.git/commitdiff
value of bound field
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 20:53:25 +0000 (23:53 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 20:53:25 +0000 (23:53 +0300)
ipf/form/boundfield.php

index 22416d8b10272d563f237b97082874fb072b11d3..5794474cd596657908440e9cdf690c8866405f63 100644 (file)
@@ -27,6 +27,14 @@ class IPF_Form_BoundField
         }
     }
 
+    public function value()
+    {
+        if ($this->form->is_bound)
+            return $this->field->widget->valueToFormData($this->html_name, $this->form->data);
+        else
+            return $this->form->initial($this->name);
+    }
+
     public function render_w($widget=null, $attrs=array())
     {
         if ($widget === null) {
@@ -37,12 +45,7 @@ class IPF_Form_BoundField
             and !array_key_exists('id', $widget->attrs)) {
             $attrs['id'] = $id;
         }
-        if (!$this->form->is_bound) {
-            $data = $this->form->initial($this->name);
-        } else {
-            $data = $this->field->widget->valueToFormData($this->html_name, $this->form->data);
-        }
-        return $widget->render($this->html_name, $data, $attrs);
+        return $widget->render($this->html_name, $this->value(), $attrs);
     }
 
     public function labelTag($contents=null, $attrs=array())