/** * @covers Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\TextFormSubmissionField::__toString */ public function testToString() { $stringValue = $this->object->__toString(); $this->assertNotNull($stringValue); $this->assertTrue(is_string($stringValue)); }
/** * 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) { $mfsf = new TextFormSubmissionField(); $mfsf->setFieldName('field_' . $this->getUniqueId()); $mfsf->setLabel($this->getLabel()); $mfsf->setSequence($sequence); $data = $formBuilder->getData(); $data['formwidget_' . $this->getUniqueId()] = $mfsf; $constraints = array(); if ($this->getRequired()) { $options = array(); if (!empty($this->errorMessageRequired)) { $options['message'] = $this->errorMessageRequired; } $constraints[] = new NotBlank($options); } if ($this->getRegex()) { $options = array('pattern' => $this->getRegex()); if (!empty($this->errorMessageRegex)) { $options['message'] = $this->errorMessageRegex; } $constraints[] = new Regex($options); } $formBuilder->add('formwidget_' . $this->getUniqueId(), TextFormSubmissionType::class, array('label' => $this->getLabel(), 'constraints' => $constraints, 'required' => $this->getRequired())); $formBuilder->setData($data); $fields->append($mfsf); }