Symfony\Component\Form\FieldGroup::setLocale PHP Method

setLocale() public method

Sets the locale of this field.
See also: Localizable
public setLocale ( $locale )
    public function setLocale($locale)
    {
        parent::setLocale($locale);

        foreach ($this->fields as $field) {
            $field->setLocale($locale);
        }
    }

Usage Example

Example #1
0
 public function testLocaleIsPassedToField_SetAfterAddingTheField()
 {
     $field = $this->getMockForAbstractClass(__NAMESPACE__ . '\\FieldGroupTest_Field', array(), '', false, false);
     $field->expects($this->any())->method('getKey')->will($this->returnValue('firstName'));
     // DOESN'T WORK!
     //    $field = $this->getMock(__NAMESPACE__ . '\Fixtures\Field', array(), array(), '', false, false);
     //    $field->expects($this->once())
     //          ->method('setLocale')
     //          ->with($this->equalTo('de_AT'));
     //    $field->expects($this->once())
     //          ->method('setLocale')
     //          ->with($this->equalTo('de_DE'));
     $group = new FieldGroup('author');
     $group->add($field);
     $group->setLocale('de_DE');
     $this->assertEquals(array(class_exists('\\Locale', false) ? \Locale::getDefault() : 'en', 'de_DE'), $field->locales);
 }