/** * Build form field * * @param DocumentType $document Document type * @param FormInterface $form Form * @param string $name Field name * @param string $type Field type * @param array $options Options * @param mixed $submittedData Submitted data * @return void */ public function buildField(DocumentType $document, FormInterface $form, $name, $type, array $options = [], $submittedData = null) { $options['type'] = $document->getChildForm($options['options']['data_class']); $options['allow_add'] = true; $options['allow_delete'] = true; $form->add($name, $type, $options); }
/** * Build form field * * @param DocumentType $document Document type * @param FormInterface $form Form * @param string $name Field name * @param string $type Field type * @param array $options Options * @param mixed $submittedData Submitted data * @return void */ public function buildField(DocumentType $document, FormInterface $form, $name, $type, array $options = [], $submittedData = null) { if (!isset($options['data_class'])) { $options['data_class'] = 'stdclass'; } // we set "required" flag to "true" if submitted data is not null // because required field cannot be a child of the optional field if (!isset($options['required']) || !$options['required']) { $options['required'] = $submittedData !== null; } $form->add($name, $document->getChildForm($options['data_class']), $options); }