[Solar-svn] Revision 2743

pmjones at solarphp.com pmjones at solarphp.com
Sat Sep 8 11:33:23 CDT 2007


branch: Solar_Form:

* [CHG] Method addInvald() no longer throws an exception when the element does not exist; instead, ignores it.

* [CHG] Method setValue() no longer throws an exception when the element does not exist; instead, ignores it.




Modified: branches/orm/Solar/Form.php
===================================================================
--- branches/orm/Solar/Form.php	2007-09-07 15:11:01 UTC (rev 2742)
+++ branches/orm/Solar/Form.php	2007-09-08 16:33:23 UTC (rev 2743)
@@ -108,8 +108,8 @@
      * The array of elements in this form.
      * 
      * The `$elements` array contains all elements in the form,
-     * including their names, types, values, any feedback messages,
-     * validation and filter callbacks, and so on. 
+     * including their names, types, values, any invalidation messages,
+     * filter callbacks, and so on. 
      * 
      * In general, you should not try to set $elements yourself;
      * instead, Solar_Form::setElement() and Solar_Form::setElements().
@@ -436,20 +436,16 @@
     {
         // make sure the element exists
         $name = $this->_prepareName($name, $array);
-        if (empty($this->elements[$name])) {
-            throw $this->_exception('ERR_NO_SUCH_ELEMENT', array(
-                'name' => $name,
-            ));
-        }
+        if (! empty($this->elements[$name])) {
+            // add the messages
+            foreach ((array) $spec as $text) {
+                $this->elements[$name]['invalid'][] = $text;
+            }
         
-        // add the messages
-        foreach ((array) $spec as $text) {
-            $this->elements[$name]['invalid'][] = $text;
+            // mark the status of the element, and of the form
+            $this->elements[$name]['status'] = false;
+            $this->_status = false;
         }
-        
-        // mark the status of the element, and of the form
-        $this->elements[$name]['status'] = false;
-        $this->_status = false;
     }
     
     /**
@@ -494,22 +490,15 @@
      * 
      * @return void
      * 
-     * @throws Solar_Form_Exception_NoSuchElement when the named element does
-     * not exist in the form.
-     * 
      */
     public function setValue($name, $value, $array = null)
     {
         // make sure the element exists
         $name = $this->_prepareName($name, $array);
-        if (empty($this->elements[$name])) {
-            throw $this->_exception('ERR_NO_SUCH_ELEMENT', array(
-                'name' => $name,
-            ));
+        if (! empty($this->elements[$name])) {
+            $this->elements[$name]['value'] = $value;
         }
         
-        // add the value
-        $this->elements[$name]['value'] = $value;
     }
     
     /**
@@ -587,7 +576,7 @@
      * 
      * 2. Validates the filtered value against the validation rules for the element,
      * 
-     * 3. Adds feedback messages to the element if it does not pass validation.
+     * 3. Adds invalidation messages to the element if it does not pass validation.
      * 
      * If all populated values pass validation, the method returns boolean
      * true, indicating the form as a whole it valid; if even one validation on




More information about the Solar-svn mailing list