add missing double-quotes to extra_fields output message
This commit is contained in:
parent
1a1a02622d
commit
9e7414159c
@ -162,13 +162,13 @@ class FormValidator extends ConstraintValidator
|
||||
if ($this->context instanceof ExecutionContextInterface) {
|
||||
$this->context->setConstraint($constraint);
|
||||
$this->context->buildViolation($config->getOption('extra_fields_message'))
|
||||
->setParameter('{{ extra_fields }}', implode('", "', array_keys($form->getExtraData())))
|
||||
->setParameter('{{ extra_fields }}', '"'.implode('", "', array_keys($form->getExtraData())).'"')
|
||||
->setInvalidValue($form->getExtraData())
|
||||
->setCode(Form::NO_SUCH_FIELD_ERROR)
|
||||
->addViolation();
|
||||
} else {
|
||||
$this->buildViolation($config->getOption('extra_fields_message'))
|
||||
->setParameter('{{ extra_fields }}', implode('", "', array_keys($form->getExtraData())))
|
||||
->setParameter('{{ extra_fields }}', '"'.implode('", "', array_keys($form->getExtraData())).'"')
|
||||
->setInvalidValue($form->getExtraData())
|
||||
->setCode(Form::NO_SUCH_FIELD_ERROR)
|
||||
->addViolation();
|
||||
|
@ -620,12 +620,33 @@ class FormValidatorTest extends AbstractConstraintValidatorTest
|
||||
$this->validator->validate($form, new Form());
|
||||
|
||||
$this->buildViolation('Extra!')
|
||||
->setParameter('{{ extra_fields }}', 'foo')
|
||||
->setParameter('{{ extra_fields }}', '"foo"')
|
||||
->setInvalidValue(array('foo' => 'bar'))
|
||||
->setCode(Form::NO_SUCH_FIELD_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testViolationFormatIfMultipleExtraFields()
|
||||
{
|
||||
$form = $this->getBuilder('parent', null, array('extra_fields_message' => 'Extra!'))
|
||||
->setCompound(true)
|
||||
->setDataMapper($this->getDataMapper())
|
||||
->add($this->getBuilder('child'))
|
||||
->getForm();
|
||||
|
||||
$form->submit(array('foo' => 'bar', 'baz' => 'qux', 'quux' => 'quuz'));
|
||||
|
||||
$this->expectNoValidate();
|
||||
|
||||
$this->validator->validate($form, new Form());
|
||||
|
||||
$this->buildViolation('Extra!')
|
||||
->setParameter('{{ extra_fields }}', '"foo", "baz", "quux"')
|
||||
->setInvalidValue(array('foo' => 'bar', 'baz' => 'qux', 'quux' => 'quuz'))
|
||||
->setCode(Form::NO_SUCH_FIELD_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testNoViolationIfAllowExtraData()
|
||||
{
|
||||
$context = $this->getMockExecutionContext();
|
||||
|
Reference in New Issue
Block a user