Development

Changeset 11362

You must first sign up to be able to contribute.

Changeset 11362

Show
Ignore:
Timestamp:
09/07/08 19:19:25 (3 months ago)
Author:
FabianLange
Message:

1.2: fixed cloning of widgetformschema fails to clone formatter correctly. fixes #4328

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/widget/sfWidgetFormSchema.class.php

    r11155 r11362  
    676676      $this[$name] = $field; 
    677677    } 
     678    foreach ($this->formFormatters as &$formFormatter) 
     679    { 
     680      $formFormatter = clone $formFormatter; 
     681      $formFormatter->setWidgetSchema($this); 
     682    } 
    678683  } 
    679684} 
  • branches/1.2/lib/widget/sfWidgetFormSchemaFormatter.class.php

    r9238 r11362  
    4040  public function __construct(sfWidgetFormSchema $widgetSchema) 
    4141  { 
    42     $this->widgetSchema = $widgetSchema
     42    $this->setWidgetSchema($widgetSchema)
    4343  } 
    4444     
     
    326326    return $this->helpFormat; 
    327327  } 
     328 
     329  public function setWidgetSchema($widgetSchema) 
     330  { 
     331    $this->widgetSchema = $widgetSchema; 
     332  } 
    328333} 
  • branches/1.2/test/unit/widget/sfWidgetFormSchemaTest.php

    r11155 r11362  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(61, new lime_output_color()); 
     13$t = new lime_test(63, new lime_output_color()); 
    1414 
    1515$w1 = new sfWidgetFormInput(array(), array('class' => 'foo1')); 
     
    349349$t->diag('__clone()'); 
    350350$w = new sfWidgetFormSchema(array('w1' => $w1, 'w2' => $w2)); 
     351$format1 = new sfWidgetFormSchemaFormatterList($w); 
     352$format1->setTranslationCatalogue('english'); 
     353$w->addFormFormatter('testFormatter', $format1); 
    351354$w1 = clone $w; 
    352355$f1 = $w1->getFields(); 
     
    358361  $t->ok($widget == $f[$name], '__clone() clones embedded widgets'); 
    359362} 
     363$format1->setTranslationCatalogue('french'); 
     364$formatters = $w1->getFormFormatters(); 
     365$t->is(count($formatters), 1 , '__clone() returns a sfWidgetFormSchema that has the Formatters attached'); 
     366$t->is($formatters['testFormatter']->getTranslationCatalogue(), 'english', '__clone() clones formatters, so that changes to the original one have no effect to the cloned formatter.'); 
    360367 
    361368// setDefaultFormFormatterName()