Fix handling required and locked attributes.
authorGunnar Wrobel <p@rdus.de>
Tue, 7 Apr 2009 05:40:40 +0000 (07:40 +0200)
committerGunnar Wrobel <p@rdus.de>
Tue, 7 Apr 2009 05:46:34 +0000 (07:46 +0200)
koward/lib/Form/Object.php

index 2924335..7a43b84 100644 (file)
@@ -127,10 +127,15 @@ class Koward_Form_Object extends Horde_Form {
                     $type = 'text';
                 }
 
+                $locked = in_array($key, $attribute_map['locked']) && !empty($this->object);
+                if (!$locked) {
+                    $required = in_array($key, $attribute_map['required'])  && empty($this->object);
+                }
+
                 $form_attributes[$key] = array(
                     'type' => $type,
-                    'required' => in_array($key, $attribute_map['required']),
-                    'readonly' => in_array($key, $attribute_map['locked']),
+                    'required' => $required,
+                    'readonly' => $locked,
                     'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255)
                 );
                 if (isset($config['attributes']['order'][$key])) {