@@ -71,16 +71,17 @@ private function _handleReadOnlyField($fieldName)
7171 if ($ this ->getWidgetSchema ()->offsetExists ($ fieldName ))
7272 {
7373 $ this ->_setWidgetReadOnly ($ fieldName );
74- try {
75- $ this ->validatorSchema [$ fieldName ] = new mmValidatorReadOnly (array (
76- 'value ' => $ this ->getObject ()->$ fieldName ,
77- 'is_new ' => $ this ->getObject ()->isNew (),
78- ));
79- } catch (Doctrine_Record_UnknownPropertyException $ e ) {
80- //It's a "virtual" field. No need to validate it since it's not going to be saved in db
81- } catch (Exception $ e ) {
82- //throw new Exception(__FILE__.':'.__LINE__.' encountered an exception: ' . $e->getMessage());
74+ if ($ this instanceof sfFormDoctrine && !$ this ->getObject ()->isNew ())
75+ {
76+ $ value = $ this ->getObject ()->$ fieldName ;
77+ }
78+ else
79+ {
80+ $ value = $ this ->getValue ($ fieldName );
8381 }
82+ $ this ->validatorSchema [$ fieldName ] = new mmValidatorReadOnly (array (
83+ 'widget ' => $ this ->validatorSchema [$ fieldName ]
84+ ));
8485 }
8586 }
8687
@@ -178,7 +179,7 @@ private function _setWidgetReadOnly($fieldName)
178179 }
179180 elseif ($ this ->widgetSchema [$ fieldName ] instanceof sfWidgetFormDate)
180181 {
181- $ this ->widgetSchema [$ fieldName ] = new mmWidgetFormDateReadOnly ();
182+ $ this ->widgetSchema [$ fieldName ] = new mmWidgetFormDateReadOnly ($ this -> widgetSchema [ $ fieldName ]-> getOptions (), $ this -> widgetSchema [ $ fieldName ]-> getAttributes () );
182183 }
183184 else
184185 {
@@ -204,7 +205,6 @@ public function setReadOnly(array $fields = array())
204205 }
205206 }
206207
207- //TODO: Also set embedded forms read-only
208208 foreach ($ this ->getEmbeddedForms () as $ f )
209209 {
210210 $ f ->setReadOnly ();
0 commit comments