Development

Changeset 11622

You must first sign up to be able to contribute.

Changeset 11622

Show
Ignore:
Timestamp:
09/17/08 20:47:31 (1 year ago)
Author:
nicolas
Message:

[1.2] forthport of r11621: fixed sfForm::mergeForm() doesn't merge widget schema labels (refs #4262)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/form/sfForm.class.php

    r11545 r11622  
    44 * This file is part of the symfony package. 
    55 * (c) Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    269269      throw new LogicException('A bound form cannot be embedded'); 
    270270    } 
    271      
     271 
    272272    $form = clone $form; 
    273273    unset($form[self::$CSRFFieldName]); 
     
    333333 
    334334  /** 
    335    * Merges current form widget and validator schemas with the ones from the  
    336    * sfForm object passed as parameter 
     335   * Merges current form widget and validator schemas with the ones from the 
     336   * sfForm object passed as parameter. Please note it also merge defaults. 
    337337   * 
    338338   * @param  sfForm   $form      The sfForm instance to merge with current form 
     339   * 
    339340   * @throws LogicException      If one of the form has already been bound 
    340341   */ 
     
    360361      $this->validatorSchema[$field] = $validator; 
    361362    } 
     363 
     364    $this->getWidgetSchema()->setLabels(array_merge($this->getWidgetSchema()->getLabels(), 
     365                                                    $form->getWidgetSchema()->getLabels())); 
    362366 
    363367    $this->mergePreValidator($form->getValidatorSchema()->getPreValidator()); 
  • branches/1.2/test/unit/form/sfFormTest.php

    r11565 r11622  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(102, new lime_output_color()); 
     13$t = new lime_test(103, new lime_output_color()); 
    1414 
    1515class FormTest extends sfForm 
     
    576576      'c' => new sfValidatorString(array('max_length' => 1000)), 
    577577    )); 
     578    $this->getWidgetSchema()->setLabels(array( 
     579      'a' => '1_a', 
     580      'b' => '1_b', 
     581      'c' => '1_c', 
     582    )); 
    578583  } 
    579584} 
     
    592597      'd' => new sfValidatorString(array('max_length' => 5)), 
    593598    )); 
     599    $this->getWidgetSchema()->setLabels(array( 
     600      'c' => '2_c', 
     601      'd' => '2_d', 
     602    )); 
    594603    $this->validatorSchema->setPreValidator(new sfValidatorPass()); 
    595604    $this->validatorSchema->setPostValidator(new sfValidatorPass()); 
     
    607616$t->is(array_keys($widgetSchema->getFields()), array('a', 'b', 'c', 'd'), 'mergeForms() merges the correct widgets'); 
    608617$t->is(array_keys($validatorSchema->getFields()), array('a', 'b', 'c', 'd'), 'mergeForms() merges the correct validators'); 
     618$t->is($widgetSchema->getLabels(), array('a' => '1_a', 'b' => '1_b', 'c' => '2_c', 'd' => '2_d'), 'mergeForm() merges labels correctly'); 
    609619$t->isa_ok($widgetSchema['c'], 'sfWidgetFormTextarea', 'mergeForm() overrides original form widget'); 
    610620$t->isa_ok($validatorSchema['c'], 'sfValidatorPass', 'mergeForm() overrides original form validator'); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.