]> git.andy128k.dev Git - ipf.git/commitdiff
verbose model column label
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 22:11:32 +0000 (01:11 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Jun 2013 22:11:32 +0000 (01:11 +0300)
ipf/form/model.php
ipf/orm/utils.php
ipf/orm/validator/verbose.php [new file with mode: 0644]

index e9511219990cc17d48857cd53de0a2180a279d5e..9c1909f084305f31a7f2de624ee5016efdef7cd9 100644 (file)
@@ -58,10 +58,16 @@ class IPF_Form_Model extends IPF_Form
 
     function addDBField($name, $col)
     {
-        if ($name==$this->model->getTable()->getIdentifier())
+        if ($name == $this->model->getTable()->getIdentifier())
             return;
 
-        $defaults = array('blank' => true, 'verbose' => $name, 'help_text' => '', 'editable' => true);
+        $defaults = array(
+            'blank' => true,
+            'help_text' => '',
+            'editable' => true,
+            'verbose'   => isset($col['verbose']) ? $col['verbose'] : $name,
+        );
+
         $type = $col['type'];
 
         if (isset($col['notblank'])) {
@@ -96,25 +102,25 @@ class IPF_Form_Model extends IPF_Form
 
     function addDBRelation($name, $relation, $col)
     {
-        if (isset($col['notblank']))
-            $blank = false;
-        else
-            $blank = true;
+        $rt = $relation->getType();
+        if ($rt !== IPF_ORM_Relation::ONE_AGGREGATE && $rt !== IPF_ORM_Relation::MANY_AGGREGATE)
+            return;
 
-        if ($relation->getType()==IPF_ORM_Relation::ONE_AGGREGATE) {
+        $defaults = array(
+            'blank'     => !isset($col['notblank']),
+            'help_text' => '',
+            'editable'  => true,
+            'model'     => $relation->getClass(),
+            'verbose'   => isset($col['verbose']) ? $col['verbose'] : $name,
+        );
+
+        if ($rt === IPF_ORM_Relation::ONE_AGGREGATE) {
             $name .= "_id";
             $db_field = new IPF_Form_DB_Foreignkey('',$name);
-            $defaults = array('blank' => $blank, 'verbose' => $name, 'help_text' => '', 'editable' => true, 'model'=>$relation->getClass());
-            $form_field = $db_field->formField($defaults);
-            $this->fields[$name] = $form_field;
-            return;
-        }
-        if ($relation->getType()==IPF_ORM_Relation::MANY_AGGREGATE) {
+            $this->fields[$name] = $db_field->formField($defaults);
+        } else if ($rt === IPF_ORM_Relation::MANY_AGGREGATE) {
             $db_field = new IPF_Form_DB_ManyToMany('',$name);
-            $defaults = array('blank' => $blank, 'verbose' => $name, 'help_text' => '', 'editable' => true, 'model'=>$relation->getClass());
-            $form_field = $db_field->formField($defaults);
-            $this->fields[$name] = $form_field;
-            return;
+            $this->fields[$name] = $db_field->formField($defaults);
         }
     }
 
index 4eba1884bd044364161f1b7ff895e8931438e285..c87e16dc17ad7b0031828a83fa0324ad4acbd981 100644 (file)
@@ -58,6 +58,7 @@ class IPF_ORM_Utils {
             'image',
             'html',
             'uploadTo',
+            'verbose',
         );
     }
 
diff --git a/ipf/orm/validator/verbose.php b/ipf/orm/validator/verbose.php
new file mode 100644 (file)
index 0000000..0a6478e
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+class IPF_ORM_Validator_Verbose
+{
+    public function validate($value)
+    {
+        return true;
+    }
+}
+