/** * Modify the form with the fields of the current page part * * @param FormBuilderInterface $formBuilder The form builder * @param ArrayObject $fields The fields * @param int $sequence The sequence of the form field */ public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence) { $ffsf = new FileFormSubmissionField(); $ffsf->setFieldName("field_" . $this->getUniqueId()); $ffsf->setLabel($this->getLabel()); $ffsf->setSequence($sequence); $data = $formBuilder->getData(); $data['formwidget_' . $this->getUniqueId()] = $ffsf; $constraints = array(); if ($this->getRequired()) { $options = array(); if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } $formBuilder->add('formwidget_' . $this->getUniqueId(), new FileFormSubmissionType(), array('label' => $this->getLabel(), 'constraints' => $constraints, 'required' => $this->getRequired())); $formBuilder->setData($data); $fields[] = $ffsf; }