/** * 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) { $efsf = new EmailFormSubmissionField(); $efsf->setFieldName("field_" . $this->getUniqueId()); $efsf->setLabel($this->getLabel()); $efsf->setSequence($sequence); $data = $formBuilder->getData(); $data['formwidget_' . $this->getUniqueId()] = $efsf; $constraints = array(); if ($this->getRequired()) { $options = array(); if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } $options = array(); if (!empty($this->errorMessageInvalid)) { $options['message'] = $this->getErrorMessageInvalid(); } $constraints[] = new Email($options); $formBuilder->add('formwidget_' . $this->getUniqueId(), new EmailFormSubmissionType(), array('label' => $this->getLabel(), 'constraints' => $constraints, 'required' => $this->getRequired())); $formBuilder->setData($data); $fields[] = $efsf; }
/** * @covers Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\EmailFormSubmissionField::__toString */ public function test__toString() { $stringValue = $this->object->__toString(); $this->assertNotNull($stringValue); $this->assertTrue(is_string($stringValue)); }