本文整理汇总了PHP中FluidTYPO3\Flux\Form::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::create方法的具体用法?PHP Form::create怎么用?PHP Form::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FluidTYPO3\Flux\Form
的用法示例。
在下文中一共展示了Form::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canSetDefaultValueFromCsvfAlreadyCorrectStrings
/**
* @test
*/
public function canSetDefaultValueFromCsvfAlreadyCorrectStrings()
{
$instance = Form::create(array())->createField('File', 'file');
$defaultValue = 'testfile1.jpg|testfile1.jpg,testfile2.jpg|testfile2.jpg';
$instance->setDefault($defaultValue);
$this->assertSame($defaultValue, $instance->getDefault());
}
示例2: renderStatic
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return void
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$viewHelperVariableContainer = $renderingContext->getViewHelperVariableContainer();
$templateVariableContainer = $renderingContext->getTemplateVariableContainer();
$extensionName = static::getExtensionNameFromRenderingContextOrArguments($renderingContext, $arguments);
$form = Form::create();
$container = $form->last();
// configure Form instance
$form->setId($arguments['id']);
$form->setName($arguments['id']);
$form->setLabel($arguments['label']);
$form->setDescription($arguments['description']);
$form->setEnabled($arguments['enabled']);
$form->setCompact($arguments['compact']);
$form->setExtensionName($extensionName);
$form->setLocalLanguageFileRelativePath($arguments['localLanguageFileRelativePath']);
$form->setVariables((array) $arguments['variables']);
$form->setOptions((array) $arguments['options']);
if (FALSE === $form->hasOption(Form::OPTION_ICON)) {
$form->setOption(Form::OPTION_ICON, $arguments['icon']);
}
if (FALSE === $form->hasOption(Form::OPTION_GROUP)) {
$form->setOption(Form::OPTION_GROUP, $arguments['wizardTab']);
}
// rendering child nodes with Form's last sheet as active container
$viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_FORM, $form);
$viewHelperVariableContainer->addOrUpdate(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME, $extensionName);
$templateVariableContainer->add(static::SCOPE_VARIABLE_FORM, $form);
static::setContainerInRenderingContext($renderingContext, $container);
$renderChildrenClosure();
$viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_EXTENSIONNAME);
$viewHelperVariableContainer->remove(static::SCOPE, static::SCOPE_VARIABLE_CONTAINER);
$templateVariableContainer->remove(static::SCOPE_VARIABLE_CONTAINER);
}
示例3: render
/**
* Render method
* @return void
*/
public function render()
{
$extensionName = $this->getExtensionName();
$form = Form::create();
$container = $form->last();
// configure Form instance
$form->setId($this->arguments['id']);
$form->setName($this->arguments['id']);
$form->setLabel($this->arguments['label']);
$form->setDescription($this->arguments['description']);
$form->setEnabled($this->arguments['enabled']);
$form->setCompact($this->arguments['compact']);
$form->setExtensionName($extensionName);
$form->setLocalLanguageFileRelativePath($this->arguments['localLanguageFileRelativePath']);
$form->setVariables((array) $this->arguments['variables']);
$form->setOptions((array) $this->arguments['options']);
if (FALSE === $form->hasOption(Form::OPTION_ICON)) {
$form->setOption(Form::OPTION_ICON, $this->arguments['icon']);
}
if (FALSE === $form->hasOption(Form::OPTION_GROUP)) {
$form->setOption(Form::OPTION_GROUP, $this->arguments['wizardTab']);
}
// rendering child nodes with Form's last sheet as active container
$this->viewHelperVariableContainer->addOrUpdate(self::SCOPE, self::SCOPE_VARIABLE_FORM, $form);
$this->viewHelperVariableContainer->addOrUpdate(self::SCOPE, self::SCOPE_VARIABLE_EXTENSIONNAME, $extensionName);
$this->templateVariableContainer->add(self::SCOPE_VARIABLE_FORM, $form);
$this->setContainer($container);
$this->renderChildren();
$this->viewHelperVariableContainer->remove(self::SCOPE, self::SCOPE_VARIABLE_EXTENSIONNAME);
$this->viewHelperVariableContainer->remove(self::SCOPE, self::SCOPE_VARIABLE_CONTAINER);
$this->templateVariableContainer->remove(self::SCOPE_VARIABLE_CONTAINER);
}
示例4: getPostProcessBackendLayoutTestValues
/**
* @return array
*/
public function getPostProcessBackendLayoutTestValues()
{
$form = Form::create(array('id' => 'formId'));
/** @var Provider|\PHPUnit_Framework_MockObject_MockObject $standardProvider */
$standardProvider = $this->getMock('FluidTYPO3\\Flux\\Provider\\Provider', array('getControllerActionFromRecord', 'getForm'));
$standardProvider->setTemplatePaths(array());
$standardProvider->expects($this->any())->method('getForm')->willReturn($form);
$actionLessProvider = clone $standardProvider;
$exceptionProvider = clone $standardProvider;
$emptyGridProvider = clone $standardProvider;
$gridProvider = clone $standardProvider;
$actionLessProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn(null);
$exceptionProvider->expects($this->any())->method('getControllerActionFromRecord')->willThrowException(new \RuntimeException());
/** @var Grid $grid */
$grid = Grid::create();
$grid->setParent($form);
$emptyGridProvider->setGrid($grid);
$emptyGridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
/** @var Grid $grid */
$grid = Grid::create(array());
$grid->setParent($form);
$grid->createContainer('Row', 'row')->createContainer('Column', 'column')->setColSpan(3)->setRowSpan(3)->setColumnPosition(2);
$gridProvider->setGrid($grid);
$gridProvider->expects($this->any())->method('getControllerActionFromRecord')->willReturn('default');
$gridArray = array('__config' => array('backend_layout.' => array('colCount' => 3, 'rowCount' => 1, 'rows.' => array('1.' => array('columns.' => array('1.' => array('name' => 'LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 'colPos' => 2, 'colspan' => 3, 'rowspan' => 3)))))), '__colPosList' => array(2), '__items' => array(array('LLL:EXT:flux/Resources/Private/Language/locallang.xlf:flux.formId.columns.column', 2, null)));
return array(array($standardProvider, null, 'message', 0, array()), array($standardProvider, array(), 'message', 1, array()), array($actionLessProvider, array(), 'message', 1, array()), array($emptyGridProvider, array(), 'message', 1, array()), array($exceptionProvider, array(), 'debug', 1, array()), array($gridProvider, array(), 'message', 0, $gridArray));
}
示例5: testTransformation
/**
* @test
* @dataProvider getValuesAndTransformations
* @param mixed $value
* @param string $transformation
* @param mixed $expected
*/
public function testTransformation($value, $transformation, $expected)
{
$instance = $this->createInstance();
$form = Form::create();
$form->createField('Input', 'field')->setTransform($transformation);
$transformed = $instance->transformAccordingToConfiguration(array('field' => $value), $form);
$this->assertTrue($transformed !== $expected, 'Transformation type ' . $transformation . ' failed; values are still identical');
}
示例6: testGetForm
/**
* @dataProvider getFormTestValues
* @param array $record
*/
public function testGetForm(array $record)
{
$instance = $this->getMock('FluidTYPO3\\FluidcontentCore\\Provider\\CoreContentProvider', array('resolveFormClassName', 'setDefaultValuesInFieldsWithInheritedValues'));
$form = Form::create();
$instance->setForm($form);
$result = $instance->getForm($record);
$this->assertInstanceOf('FluidTYPO3\\Flux\\Form', $result);
}
示例7: modifyModifiesFields
/**
* @test
*/
public function modifyModifiesFields()
{
$form = Form::create();
$sheet = $form->createContainer('Sheet', 'testsheet');
$field = $sheet->createField('Input', 'testfield', 'Testfield');
$sheet->modify(array('fields' => array('testfield' => array('label' => 'Test'))));
$fields = $sheet->getFields();
$this->assertEquals('Test', reset($fields)->getLabel());
}
示例8: triggersDomainModelAnalysisWhenFormsAreRegistered
/**
* @test
*/
public function triggersDomainModelAnalysisWhenFormsAreRegistered()
{
$class = 'FluidTYPO3\\Flux\\Domain\\Model\\Dummy';
$form = Form::create();
Core::registerAutoFormForModelObjectClassName($class);
$object = GeneralUtility::getUserObj('FluidTYPO3\\Flux\\Backend\\TableConfigurationPostProcessor');
$object->processData();
Core::registerFormForModelObjectClassName($class, $form);
$object->processData();
}
示例9: testDetectAndRegisterAllFluidBackendModules
/**
* @return void
*/
public function testDetectAndRegisterAllFluidBackendModules()
{
$form = Form::create();
$instance = $this->getMock('FluidTYPO3\\Fluidbackend\\Service\\ConfigurationService', array('getBackendModuleTemplatePaths', 'getFormFromTemplateFile', 'registerModuleBasedOnFluxForm'));
$paths = new TemplatePaths('FluidTYPO3.Fluidbackend');
$instance->expects($this->once())->method('getBackendModuleTemplatePaths')->willReturn(array('FluidTYPO3.Fluidbackend' => $paths->toArray()));
$instance->expects($this->atLeastOnce())->method('registerModuleBasedOnFluxForm');
$instance->expects($this->atLeastOnce())->method('getFormFromTemplateFile')->willReturn($form);
$instance->detectAndRegisterAllFluidBackendModules();
}
示例10: testTransformation
/**
* @test
* @dataProvider getValuesAndTransformations
* @param mixed $value
* @param string $transformation
* @param mixed $expected
*/
public function testTransformation($value, $transformation, $expected)
{
$instance = $this->getMock('FluidTYPO3\\Flux\\Transformation\\FormDataTransformer', array('loadObjectsFromRepository'));
$instance->expects($this->any())->method('loadObjectsFromRepository')->willReturn(array());
$instance->injectObjectManager($this->objectManager);
$form = Form::create();
$form->createField('Input', 'field')->setTransform($transformation);
$transformed = $instance->transformAccordingToConfiguration(array('field' => $value), $form);
$this->assertTrue($transformed !== $expected, 'Transformation type ' . $transformation . ' failed; values are still identical');
}
示例11: testRender
/**
* @test
*/
public function testRender()
{
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'] = array();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeResolver'] = array();
$form = Form::create();
$nodeFactory = $this->getMock(NodeFactory::class, array('create'));
$nodeFactory->expects($this->once())->method('create')->willReturn($this->getMock(NodeInterface::class));
$instance = $this->getMock($this->createInstanceClassName(), array('getNodeFactory'));
$instance->expects($this->once())->method('getNodeFactory')->willReturn($nodeFactory);
$instance->render($form);
}
示例12: testRenderWizardTabItem
public function testRenderWizardTabItem()
{
$form = Form::create();
$form->setLabel('bazlabel');
$form->setDescription('foobar');
$service = $this->getMock('FluidTYPO3\\Fluidcontent\\Service\\ConfigurationService', array(), array(), '', FALSE);
$result = $this->callInaccessibleMethod($service, 'buildWizardTabItem', 'tabid', 'id', $form, '');
$this->assertContains('tabid.elements.id', $result);
$this->assertContains('title = bazlabel', $result);
$this->assertContains('description = foobar', $result);
}
示例13: testRender
/**
* @test
*/
public function testRender()
{
$form = Form::create();
$engine = $this->getMock('TYPO3\\CMS\\Backend\\Form\\FormEngine', array('printNeededJSFunctions_top', 'getSoloField', 'printNeededJSFunctions'), array(), '', FALSE);
$engine->expects($this->once())->method('printNeededJSFunctions_top')->willReturn('1');
$engine->expects($this->once())->method('getSoloField')->willReturn('2');
$engine->expects($this->once())->method('printNeededJSFunctions')->willReturn('3');
$instance = $this->getMock($this->createInstanceClassName(), array('getFormEngine'));
$instance->expects($this->once())->method('getFormEngine')->willReturn($engine);
$result = $instance->render($form);
$this->assertEquals('123', $result);
}
示例14: getForm
/**
* @return Form
*/
protected function getForm()
{
if (TRUE === $this->viewHelperVariableContainer->exists(self::SCOPE, self::SCOPE_VARIABLE_FORM)) {
$form = $this->viewHelperVariableContainer->get(self::SCOPE, self::SCOPE_VARIABLE_FORM);
} elseif (TRUE === $this->templateVariableContainer->exists(self::SCOPE_VARIABLE_FORM)) {
$form = $this->templateVariableContainer->get(self::SCOPE_VARIABLE_FORM);
} else {
$form = Form::create();
$this->viewHelperVariableContainer->add(self::SCOPE, self::SCOPE_VARIABLE_FORM, $form);
}
return $form;
}
示例15: triggersDomainModelAnalysisWhenFormsAreRegistered
/**
* @test
*/
public function triggersDomainModelAnalysisWhenFormsAreRegistered()
{
$class = 'FluidTYPO3\\Flux\\Tests\\Fixtures\\Classes\\Domain\\Model\\Dummy';
$form = Form::create();
$form->setExtensionName('FluidTYPO3.Flux');
Core::registerAutoFormForModelObjectClassName($class);
$object = GeneralUtility::getUserObj('FluidTYPO3\\Flux\\Backend\\TableConfigurationPostProcessor');
$object->processData();
Core::registerFormForModelObjectClassName($class, $form);
$result = $object->processData();
$this->assertEmpty($result);
}