merged branch bschussek/violationmapperfix (PR #4414)
Commits -------8c23d7f
[Form] Fixed: "error_mapping" is not an attribute anymore, but an option Discussion ---------- [Form] Fixed: "error_mapping" is not an attribute anymore, but an option Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #4411 Todo: - --------------------------------------------------------------------------- by craue at 2012-05-25T14:56:34Z 👍 --------------------------------------------------------------------------- by travisbot at 2012-05-25T14:58:41Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1433732) (merged8c23d7fd
into023dbf80
).
This commit is contained in:
commit
ff4d446c5e
@ -109,12 +109,12 @@ class ViolationMapper implements ViolationMapperInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Follow dot rules until we have the final target
|
// Follow dot rules until we have the final target
|
||||||
$mapping = $this->scope->getConfig()->getAttribute('error_mapping');
|
$mapping = $this->scope->getConfig()->getOption('error_mapping');
|
||||||
|
|
||||||
while ($this->isValidScope() && isset($mapping['.'])) {
|
while ($this->isValidScope() && isset($mapping['.'])) {
|
||||||
$dotRule = new MappingRule($this->scope, '.', $mapping['.']);
|
$dotRule = new MappingRule($this->scope, '.', $mapping['.']);
|
||||||
$this->scope = $dotRule->getTarget();
|
$this->scope = $dotRule->getTarget();
|
||||||
$mapping = $this->scope->getConfig()->getAttribute('error_mapping');
|
$mapping = $this->scope->getConfig()->getOption('error_mapping');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add the error if the form is synchronized
|
// Only add the error if the form is synchronized
|
||||||
@ -281,7 +281,7 @@ class ViolationMapper implements ViolationMapperInterface
|
|||||||
$this->children = new \RecursiveIteratorIterator(
|
$this->children = new \RecursiveIteratorIterator(
|
||||||
new VirtualFormAwareIterator($form->all())
|
new VirtualFormAwareIterator($form->all())
|
||||||
);
|
);
|
||||||
foreach ($form->getConfig()->getAttribute('error_mapping') as $propertyPath => $targetPath) {
|
foreach ($form->getConfig()->getOption('error_mapping') as $propertyPath => $targetPath) {
|
||||||
// Dot rules are considered at the very end
|
// Dot rules are considered at the very end
|
||||||
if ('.' !== $propertyPath) {
|
if ('.' !== $propertyPath) {
|
||||||
$this->rules[] = new MappingRule($form, $propertyPath, $targetPath);
|
$this->rules[] = new MappingRule($form, $propertyPath, $targetPath);
|
||||||
|
@ -68,11 +68,12 @@ class ViolationMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $virtual = false, $synchronized = true)
|
protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $virtual = false, $synchronized = true)
|
||||||
{
|
{
|
||||||
$config = new FormConfig($name, $dataClass, $this->dispatcher);
|
$config = new FormConfig($name, $dataClass, $this->dispatcher, array(
|
||||||
|
'error_mapping' => $errorMapping,
|
||||||
|
));
|
||||||
$config->setMapped(true);
|
$config->setMapped(true);
|
||||||
$config->setVirtual($virtual);
|
$config->setVirtual($virtual);
|
||||||
$config->setPropertyPath($propertyPath);
|
$config->setPropertyPath($propertyPath);
|
||||||
$config->setAttribute('error_mapping', $errorMapping);
|
|
||||||
|
|
||||||
if (!$synchronized) {
|
if (!$synchronized) {
|
||||||
$config->addViewTransformer(new CallbackTransformer(
|
$config->addViewTransformer(new CallbackTransformer(
|
||||||
|
Reference in New Issue
Block a user