- $annotation->setText($data['text']);
- if (array_key_exists('quote', $data)) {
- $annotation->setQuote($data['quote']);
- }
- if (array_key_exists('ranges', $data)) {
- $annotation->setRanges($data['ranges']);
- }
+ $form = $this->get('form.factory')->createNamed('', NewAnnotationType::class, $annotation, [
+ 'csrf_protection' => false,
+ 'allow_extra_fields' => true,
+ ]);
+ $form->submit($data);