Author: sevein
Date: Tue Jul 12 14:20:22 2011
New Revision: 9305

Log:
Add process form

Modified:
   
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php

Modified: 
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
    Tue Jul 12 14:17:40 2011        (r9304)
+++ 
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
    Tue Jul 12 14:20:22 2011        (r9305)
@@ -84,6 +84,58 @@
     }
   }
 
+  public function processForm()
+  {
+    // HACK For now, parameter name and action name are the same. Should
+    // really be configurable, ideally by interpreting
+    // $form->getWidgetSchema()->getNameFormat()?
+    $params = array($this->request[$this->actionName]);
+    if (isset($this->request["{$this->actionName}s"]))
+    {
+      // If dialog JavaScript did it's work, then use array of parameters
+      $params = $this->request["{$this->actionName}s"];
+    }
+
+    foreach ($params as $item)
+    {
+      // Continue only if user typed something
+      foreach ($item as $value)
+      {
+        if (0 < strlen($value))
+        {
+          break;
+        }
+      }
+
+      if (1 > strlen($value))
+      {
+        continue;
+      }
+
+      $this->form->bind($item);
+      if ($this->form->isValid())
+      {
+        if (isset($item['id']))
+        {
+          $params = 
$this->context->routing->parse(Qubit::pathInfo($item['id']));
+          $this->relation = $params['_sf_route']->resource;
+        }
+        else
+        {
+          $this->resource->relationsRelatedBysubjectId[] = $this->relation = 
new QubitRelation;
+        }
+
+        foreach ($this->form as $field)
+        {
+          if (isset($item[$field->getName()]))
+          {
+            $this->processField($field);
+          }
+        }
+      }
+    }
+  }
+
   public function execute($request)
   {
     $this->form = new sfForm;

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to