symfony/symfony — Issue #2383: Quotes inside an attribute get converted when inside a form collection
Author: jdewit
Created: 2011-10-11 22:27:31+00:00
State: open

I am experiencing a problem with setting an attribute in a form element that occurs only inside collections.

Symfony2 is converting quotes inside the attribute setter into their html entity. (single quote becomes ')

For example...
$builder
->add('service', 'entity', array(
'class' => 'Dewit\TestBundle\Entity\Service',
'query_builder' => function ($repository) use ($owner) { return $repository->createQueryBuilder('c')->where('c.active = ?1')->setParameter('1', true; },
'attr' => array(
"data-bind" => "
value: selectedService,
options: services,
optionsValue: 'id',
optionsText: 'name' "
)
));

view output:

I am using KnockoutJS so the quotes are required to indicate a string.

I expect:

As I said, this special character conversion does not occur when not used inside a form collection.