예제 #1
0
 public function testGetters()
 {
     $testData = ['name' => 'petro', 'email' => '*****@*****.**'];
     $data = new FormData(FormData::METHOD_POST, $testData);
     $this->assertEquals(FormData::METHOD_POST, $data->getMethod());
     $this->assertFalse($data->isMethod(FormData::METHOD_GET));
     $this->assertTrue($data->isMethod(FormData::METHOD_POST));
     $this->assertEquals(['name' => 'petro', 'email' => '*****@*****.**'], $data->getData());
     $this->assertEquals('petro', $data->get('name'));
     $this->assertNull($data->get('age'));
     $this->assertTrue($data->has('email'));
     $this->assertFalse($data->has('age'));
 }
예제 #2
0
파일: Form.php 프로젝트: sevikerr/form
 /**
  * @param FormData $data
  * @return $this
  */
 public function handle(FormData $data)
 {
     $this->cleanValidationFlag();
     $this->isSubmitted = false;
     if ($data->isMethod($this->getMethod()) and $data->has($this->getUid())) {
         $this->isSubmitted = true;
         foreach ($this->getElements() as $element) {
             $element->handle($data);
         }
     }
     return $this;
 }