当前位置: 首页>>代码示例>>PHP>>正文


PHP FormConfigBuilder::setAttribute方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\FormConfigBuilder::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormConfigBuilder::setAttribute方法的具体用法?PHP FormConfigBuilder::setAttribute怎么用?PHP FormConfigBuilder::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\FormConfigBuilder的用法示例。


在下文中一共展示了FormConfigBuilder::setAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testbuildViewWithWithSonataAdmin

 public function testbuildViewWithWithSonataAdmin()
 {
     $admin = $this->getMock('Sonata\\AdminBundle\\Admin\\AdminInterface');
     $admin->expects($this->once())->method('getCode')->will($this->returnValue('my.admin.reference'));
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $formView = new FormView();
     $options = array();
     $config = new FormConfigBuilder('test', 'stdClass', $eventDispatcher, $options);
     $config->setAttribute('sonata_admin', array('admin' => $admin, 'name' => 'name'));
     $config->setAttribute('sonata_admin_enabled', true);
     $form = new Form($config);
     $formView->vars['block_prefixes'] = array('form', 'field', 'text', '_s50b26aa76cb96_username');
     $extension = new FormTypeFieldExtension();
     $extension->buildView($formView, $form, array());
     $this->assertArrayHasKey('block_prefixes', $formView->vars);
     $this->assertArrayHasKey('sonata_admin_enabled', $formView->vars);
     $this->assertArrayHasKey('sonata_admin', $formView->vars);
     $expected = array('form', 'field', 'text', 'my_admin_reference_text', 'my_admin_reference_name_text', 'my_admin_reference_name_text_username');
     $this->assertEquals($expected, $formView->vars['block_prefixes']);
     $this->assertTrue($formView->vars['sonata_admin_enabled']);
 }
开发者ID:r1pp3rj4ck,项目名称:SonataAdminBundle,代码行数:21,代码来源:FormTypeFieldExtensionTest.php

示例2: testbuildViewWithNestedForm

 public function testbuildViewWithNestedForm()
 {
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $formView = new FormView();
     $formView->vars['name'] = 'format';
     $options = array();
     $config = new FormConfigBuilder('test', 'stdClass', $eventDispatcher, $options);
     $config->setAttribute('sonata_admin', array('admin' => false));
     $form = new Form($config);
     $formView->parent = new FormView();
     $formView->parent->vars['sonata_admin_enabled'] = true;
     $formView->parent->vars['sonata_admin_code'] = 'parent_code';
     $formView->parent->vars['name'] = 'settings';
     $formView->vars['block_prefixes'] = array('form', 'field', 'text', '_s50b26aa76cb96_settings_format');
     $extension = new FormTypeFieldExtension(array(), array());
     $extension->buildView($formView, $form, array('sonata_help' => 'help text'));
     $this->assertArrayHasKey('block_prefixes', $formView->vars);
     $this->assertArrayHasKey('sonata_admin_enabled', $formView->vars);
     $this->assertArrayHasKey('sonata_admin', $formView->vars);
     $expected = array('value' => null, 'attr' => array(), 'name' => 'format', 'block_prefixes' => array('form', 'field', 'text', 'parent_code_text', 'parent_code_text_settings_format', 'parent_code_text_settings_settings_format'), 'sonata_admin_enabled' => true, 'sonata_admin' => array('admin' => false, 'field_description' => false, 'name' => false, 'edit' => 'standard', 'inline' => 'natural', 'block_name' => false, 'class' => false, 'options' => array()), 'sonata_admin_code' => 'parent_code');
     $this->assertEquals($expected, $formView->vars);
 }
开发者ID:jerome-fix,项目名称:SonataAdminBundle,代码行数:22,代码来源:FormTypeFieldExtensionTest.php


注:本文中的Symfony\Component\Form\FormConfigBuilder::setAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。