CodeExplorer MergeDoctrineCollectionListener example
protected function getBuilder() { return new FormBuilder('name', null,
$this->dispatcher,
$this->factory
);
} protected function getForm() { return $this->
getBuilder() ->
setData($this->collection
) ->
addEventSubscriber(new MergeDoctrineCollectionListener()) ->
getForm();
} public function testOnSubmitDoNothing() { $submittedData =
['test'
];
$event =
new FormEvent($this->
getForm(),
$submittedData);
$this->dispatcher->
dispatch($event, FormEvents::SUBMIT
);
$this->
assertTrue($this->collection->
contains('test'
));
$this->registry =
$registry;
} /**
* @return void
*/
public function buildForm(FormBuilderInterface
$builder, array
$options) { if ($options['multiple'
] &&
interface_exists(Collection::
class)) { $builder ->
addEventSubscriber(new MergeDoctrineCollectionListener()) ->
addViewTransformer(new CollectionToArrayTransformer(), true
) ;
} } /**
* @return void
*/
public function configureOptions(OptionsResolver
$resolver) { $choiceLoader =
function DOptions
$options) {