Returns the normalized data of the field.
public getNormData ( ) : mixed | ||
return | mixed | When the field is not bound, the default data is returned. When the field is bound, the normalized bound data is returned if the field is valid, null otherwise. |
public function testRequestWithValidJsonShouldPopulateForm() { $request = $this->getRequest('{ "name": "test1" }'); $this->form->handleRequest($request); $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getData()); $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getNormData()); $this->assertEquals(['name' => 'test1', 'lastname' => null], $this->form->getViewData()); }
public function testDataIsInitializedEmpty() { $norm = new FixedDataTransformer(array('' => 'foo')); $client = new FixedDataTransformer(array('foo' => 'bar')); $form = new Form('name', $this->dispatcher, array(), array($client), array($norm)); $this->assertNull($form->getData()); $this->assertSame('foo', $form->getNormData()); $this->assertSame('bar', $form->getClientData()); }
public function testDataIsInitializedEmpty() { $model = new FixedDataTransformer(array('' => 'foo')); $view = new FixedDataTransformer(array('foo' => 'bar')); $config = new FormConfig('name', null, $this->dispatcher); $config->addViewTransformer($view); $config->addModelTransformer($model); $form = new Form($config); $this->assertNull($form->getData()); $this->assertSame('foo', $form->getNormData()); $this->assertSame('bar', $form->getViewData()); }
public function testDataIsInitializedToConfiguredValue() { $model = new FixedDataTransformer(array('default' => 'foo')); $view = new FixedDataTransformer(array('foo' => 'bar')); $config = new FormConfigBuilder('name', null, $this->dispatcher); $config->addViewTransformer($view); $config->addModelTransformer($model); $config->setData('default'); $form = new Form($config); $this->assertSame('default', $form->getData()); $this->assertSame('foo', $form->getNormData()); $this->assertSame('bar', $form->getViewData()); }