本文整理汇总了PHP中Symfony\Component\Form\FormConfigBuilder::addModelTransformer方法的典型用法代码示例。如果您正苦于以下问题:PHP FormConfigBuilder::addModelTransformer方法的具体用法?PHP FormConfigBuilder::addModelTransformer怎么用?PHP FormConfigBuilder::addModelTransformer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormConfigBuilder
的用法示例。
在下文中一共展示了FormConfigBuilder::addModelTransformer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDataTransformationFailure
/**
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
* @expectedExceptionMessage Unable to transform value for property path "name": No mapping for value "arg"
*/
public function testDataTransformationFailure()
{
$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('arg');
$form = new Form($config);
$form->getData();
}
示例2: testDataIsInitializedToConfiguredValue
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());
}