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


PHP AdminInterface::getFormFieldDescription方法代码示例

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


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

示例1: testWithFieldsCascadeTranslationDomain

 public function testWithFieldsCascadeTranslationDomain()
 {
     $this->contractor->expects($this->once())->method('getDefaultOptions')->will($this->returnValue(array()));
     $this->formMapper->with('foobar', array('translation_domain' => 'Foobar'))->add('foo', 'bar')->end();
     $fieldDescription = $this->admin->getFormFieldDescription('foo');
     $this->assertSame('foo', $fieldDescription->getName());
     $this->assertSame('bar', $fieldDescription->getType());
     $this->assertSame('Foobar', $fieldDescription->getTranslationDomain());
     $this->assertTrue($this->formMapper->has('foo'));
     $this->assertSame(array('default' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'default', 'box_class' => 'box box-primary', 'auto_created' => true, 'groups' => array('foobar'), 'tab' => true)), $this->admin->getFormTabs());
     $this->assertSame(array('foobar' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'foobar', 'box_class' => 'box box-primary', 'fields' => array('foo' => 'foo'))), $this->admin->getFormGroups());
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:12,代码来源:FormMapperTest.php

示例2: appendFormFieldElement

 /**
  * @param AdminInterface $admin
  * @param object $subject
  * @param string $elementId
  * @return array
  */
 public function appendFormFieldElement(AdminInterface $admin, $subject, $elementId)
 {
     // retrieve the subject
     $formBuilder = $admin->getFormBuilder();
     $form = $formBuilder->getForm();
     $form->setData($subject);
     $form->submit($admin->getRequest());
     // get the field element
     $childFormBuilder = $this->getChildFormBuilder($formBuilder, $elementId);
     // retrieve the FieldDescription
     $fieldDescription = $admin->getFormFieldDescription($childFormBuilder->getName());
     try {
         $value = $fieldDescription->getValue($form->getData());
     } catch (NoValueException $e) {
         $value = null;
     }
     // retrieve the posted data
     $data = $admin->getRequest()->get($formBuilder->getName());
     if (!isset($data[$childFormBuilder->getName()])) {
         $data[$childFormBuilder->getName()] = array();
     }
     $objectCount = count($value);
     $postCount = count($data[$childFormBuilder->getName()]);
     $fields = array_keys($fieldDescription->getAssociationAdmin()->getFormFieldDescriptions());
     // for now, not sure how to do that
     $value = array();
     foreach ($fields as $name) {
         $value[$name] = '';
     }
     // add new elements to the subject
     while ($objectCount <= $postCount) {
         // append a new instance into the object
         $this->addNewInstance($form->getData(), $fieldDescription);
         $objectCount++;
     }
     $subject->orderLayoutBlocks();
     $finalForm = $admin->getFormBuilder()->getForm();
     $finalForm->setData($subject);
     // bind the data
     $finalForm->setData($form->getData());
     return array($fieldDescription, $finalForm);
 }
开发者ID:rapemer,项目名称:init-cms-bundle,代码行数:48,代码来源:PageAdminHelper.php

示例3: retrieveFormFieldDescription

 /**
  * Retrieve the form field description given by field name.
  *
  * @param AdminInterface $admin
  * @param string         $field
  *
  * @return FormInterface
  *
  * @throws \RuntimeException
  */
 private function retrieveFormFieldDescription(AdminInterface $admin, $field)
 {
     $admin->getFormFieldDescriptions();
     $fieldDescription = $admin->getFormFieldDescription($field);
     if (!$fieldDescription) {
         throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
     }
     if (null === $fieldDescription->getTargetEntity()) {
         throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
     }
     return $fieldDescription;
 }
开发者ID:vincenttouzet,项目名称:SonataAdminBundle,代码行数:22,代码来源:HelperController.php

示例4: getClassInstance

 protected function getClassInstance(AdminInterface $admin, $elements)
 {
     $element = array_shift($elements);
     $associationAdmin = $admin->getFormFieldDescription($element)->getAssociationAdmin();
     if (count($elements) == 0) {
         return $associationAdmin->getNewInstance();
     } else {
         return $this->getClassInstance($associationAdmin, $elements);
     }
 }
开发者ID:kwuerl,项目名称:SonataAdminBundle,代码行数:10,代码来源:AdminHelper.php

示例5: retrieveFieldDescription

 /**
  * Retrieve the field description given by field name.
  *
  * @param AdminInterface $admin
  * @param string         $field
  *
  * @return \Symfony\Component\Form\FormInterface
  *
  * @throws \RuntimeException
  */
 private function retrieveFieldDescription(AdminInterface $admin, $field)
 {
     $admin->getFormFieldDescriptions();
     $fieldDescription = $admin->getFormFieldDescription($field);
     if (!$fieldDescription) {
         throw new \RuntimeException(sprintf('The field "%s" does not exist.', $field));
     }
     if ($fieldDescription->getType() !== 'sonata_type_model_autocomplete') {
         throw new \RuntimeException(sprintf('Unsupported form type "%s" for field "%s".', $fieldDescription->getType(), $field));
     }
     if (null === $fieldDescription->getTargetEntity()) {
         throw new \RuntimeException(sprintf('No associated entity with field "%s".', $field));
     }
     return $fieldDescription;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:25,代码来源:HelperController.php

示例6: getEntityClassName

 /**
  * Recursively find the class name of the admin responsible for the element at the end of an association chain.
  *
  * @param AdminInterface $admin
  * @param array          $elements
  *
  * @return string
  */
 protected function getEntityClassName(AdminInterface $admin, $elements)
 {
     $element = array_shift($elements);
     $associationAdmin = $admin->getFormFieldDescription($element)->getAssociationAdmin();
     if (count($elements) == 0) {
         return $associationAdmin->getClass();
     }
     return $this->getEntityClassName($associationAdmin, $elements);
 }
开发者ID:ejkun,项目名称:SonataAdminBundle,代码行数:17,代码来源:AdminHelper.php


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