本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::get方法的具体用法?PHP FormBuilder::get怎么用?PHP FormBuilder::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildPagerWithPage2
/**
* @dataProvider getBuildPagerWithPage2Tests
*/
public function testBuildPagerWithPage2($page, $perPage)
{
$this->pager->expects($this->once())->method('setMaxPerPage')->with($this->equalTo('50'))->will($this->returnValue(null));
$this->pager->expects($this->once())->method('setPage')->with($this->equalTo('3'))->will($this->returnValue(null));
$this->datagrid = new Datagrid($this->query, $this->columns, $this->pager, $this->formBuilder, array());
$this->datagrid->setValue('_per_page', null, $perPage);
$this->datagrid->setValue('_page', null, $page);
$this->datagrid->buildPager();
$this->assertSame(array('_per_page' => array('type' => null, 'value' => $perPage), '_page' => array('type' => null, 'value' => $page)), $this->datagrid->getValues());
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_by'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_order'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_page'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_per_page'));
}
示例2: testBuildPagerWithSortBy
public function testBuildPagerWithSortBy()
{
$this->datagrid = new Datagrid($this->query, $this->pager, $this->formBuilder, array('_sort_by' => 'name'));
$filter = $this->getMock('Sonata\\DatagridBundle\\Filter\\FilterInterface');
$filter->expects($this->once())->method('getName')->will($this->returnValue('foo'));
$filter->expects($this->any())->method('getFormName')->will($this->returnValue('fooFormName'));
$filter->expects($this->any())->method('isActive')->will($this->returnValue(false));
$filter->expects($this->any())->method('getRenderSettings')->will($this->returnValue(array('foo', array('bar' => 'baz'))));
$this->datagrid->addFilter($filter);
$this->datagrid->buildPager();
$this->assertEquals(array('_sort_by' => 'name', 'foo' => null), $this->datagrid->getValues());
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('fooFormName'));
$this->assertEquals(array('bar' => 'baz'), $this->formBuilder->get('fooFormName')->getOptions());
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_by'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_sort_order'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_page'));
$this->assertInstanceOf('Symfony\\Component\\Form\\FormBuilder', $this->formBuilder->get('_per_page'));
}
示例3: buildFormElement
public function buildFormElement(\Symfony\Bundle\FrameworkBundle\Controller\Controller $controller, \Symfony\Component\Form\FormBuilder $builder, \Symforce\AdminBundle\Compiler\Cache\AdminCache $admin, \Symforce\AdminBundle\Compiler\Cache\ActionCache $action, $object, $property_name, $parent_property)
{
if ($object) {
if (!$object instanceof $admin->class_name) {
throw new \Exception();
}
if ($admin->workflow) {
if ($admin !== $this) {
throw new \Exception();
}
$status = $admin->getObjectWorkflowStatus($object);
if (!isset($status['properties'][$property_name])) {
return;
}
$flag = $status['properties'][$property_name];
$readable = \Symforce\AdminBundle\Compiler\MetaType\Admin\Workflow::FLAG_VIEW & $flag;
$editable = \Symforce\AdminBundle\Compiler\MetaType\Admin\Workflow::FLAG_EDIT & $flag;
if (\Symforce\AdminBundle\Compiler\MetaType\Admin\Workflow::FLAG_AUTH & $flag) {
if ($readable || $editable) {
throw new \Exception();
}
$securityContext = $this->container->get('security.context');
$user = $securityContext->getToken()->getUser();
$group = $user->getUserGroup();
if ($group) {
$flag = $group->getWorkflowPropertyVisiable($this->name, $property_name, $status['name']);
if ('1' === $flag) {
$editable = true;
} else {
if ('2' === $flag) {
$readable = true;
}
}
}
}
if ($readable) {
$options = array();
$_options = $admin->getFormBuilderOption($property_name, $action, $object);
if ($_options) {
$options['label'] = $_options['label'];
}
$builder->add($property_name, 'sf_view', $options);
return;
}
if (!$editable) {
return;
}
}
}
$options = $admin->getFormBuilderOption($property_name, $action, $object);
$type = $options['sf_form_type'];
if (isset($options['read_only']) && $options['read_only']) {
if (in_array($type, array('sf_owner', 'sf_entity', 'sf_workflow', 'choice', 'checkbox', 'sf_file', 'sf_image', 'sf_html', 'money'))) {
$options = array();
$_options = $admin->getFormBuilderOption($property_name, $action, $object);
if ($_options) {
$options['label'] = $_options['label'];
}
$builder->add($property_name, 'sf_view', $options);
return;
}
}
if (isset($options['required']) && $options['required']) {
if (!isset($options['constraints'])) {
$options['constraints'] = array(new \Symfony\Component\Validator\Constraints\NotBlank());
} else {
$find_not_blank = false;
foreach ($options['constraints'] as $_constraint) {
if ($_constraint instanceof \Symfony\Component\Validator\Constraints\NotBlank) {
$find_not_blank = true;
}
}
if (!$find_not_blank) {
$options['constraints'][] = new \Symfony\Component\Validator\Constraints\NotBlank();
}
}
}
/**
* @FIXME since symfony 2.7, without this hack radio(value=0) will not get checked
*/
if ('bool' == $options['sf_form_meta']) {
if ($object) {
$options['data'] = $admin->getReflectionProperty($property_name)->getValue($object) ? 1 : 0;
} else {
$options['data'] = 0;
}
}
$this->adjustFormOptions($object, $property_name, $options);
$subscribers = null;
if (isset($options['subscribers'])) {
$subscribers = $options['subscribers'];
unset($options['subscribers']);
}
$builder->add($property_name, $type, $options);
if ($subscribers) {
$_builder = $builder->get($property_name);
foreach ($subscribers as $subscriber) {
$events = $subscriber->getSubscribedEvents();
foreach ($events as $_event => $method) {
$_builder->addEventListener($_event, array($subscriber, $method));
//.........这里部分代码省略.........
示例4: userFormUpdate
protected function userFormUpdate($action, $row, \Symfony\Component\Form\FormBuilder $form)
{
$this->origUserPassword = $row->getPassword();
$form->get('valid')->setRequired(false);
$adminFormEvent = new AdminFormEvent($action, $row, $form);
$this->get('event_dispatcher')->dispatch(AdminFormEvent::UPDATE_USER, $adminFormEvent);
}