コード例 #1
0
ファイル: RequestContextTest.php プロジェクト: sevikerr/form
 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;
 }