Exemple #1
0
 public function testGetElements()
 {
     $this->mockTextElement();
     $this->fb->register('text', 'Boyhagemann\\Form\\Element\\Text');
     $this->fb->text('test');
     $elements = $this->fb->getElements();
     $this->assertInternalType('array', $elements);
     $this->assertCount(1, $elements);
     $this->assertSame('test', key($elements));
     // Name of the element
     $this->assertInstanceof('Boyhagemann\\Form\\Element\\Text', current($elements));
 }
 /**
  * Seed the form with defaults that are stored in the session
  *
  * @param FormBuilder $fb
  */
 public function onBuildForm(FormBuilder $fb)
 {
     foreach ($fb->getElements() as $element) {
         if (!$element instanceof FileElement) {
             continue;
         }
         if (!$fb->getAttribute('enctype') == 'multipart/form-data') {
             $fb->attr('enctype', 'multipart/form-data');
         }
     }
 }