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


PHP FormMapper::remove方法代码示例

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


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

示例1: buildForm

 public function buildForm(AdminInterface $admin, FormMapper $formMapper)
 {
     /**
      * Bind data to the mapped fields
      */
     $formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $formEvent) {
         $data = $formEvent->getData();
         $form = $formEvent->getForm();
         if ($data instanceof Route) {
             $form->get('source')->setData($data->getPath());
             $form->get('target')->setData($data->getDefault('path'));
         }
     });
     /**
      * Bind the mapped fields to the entity
      */
     $formMapper->getFormBuilder()->addEventListener(FormEvents::SUBMIT, function (FormEvent $formEvent) {
         $data = $formEvent->getData();
         $form = $formEvent->getForm();
         if ($data instanceof Route) {
             $data->setStaticPrefix($form->get('source')->getData());
             $data->setDefault('path', $form->get('target')->getData());
             $data->setDefault('_controller', $this->routeController);
             $data->setDefault('permanent', true);
         }
     });
     $formMapper->add('source', 'text', ['mapped' => false]);
     $formMapper->add('target', 'text', ['mapped' => false]);
     $formMapper->remove('staticPrefix');
     $formMapper->remove('variablePattern');
 }
开发者ID:gravity-cms,项目名称:cms-bundle,代码行数:31,代码来源:RedirectType.php

示例2: testRemoveCascadeRemoveFieldFromFormGroup

 public function testRemoveCascadeRemoveFieldFromFormGroup()
 {
     $this->formMapper->with('foo');
     $this->formMapper->remove('foo');
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:5,代码来源:FormMapperTest.php

示例3: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     // Verify if document is not child
     $isParent = $this->getParentFieldDescription() === null;
     $hasRouteChild = method_exists($this->getClass(), 'getRouteChild');
     $adminClassname = $this->getClassName();
     $notMenuAdmin = $adminClassname != 'MenuAdmin';
     if ($isParent && $hasRouteChild && $notMenuAdmin) {
         $formMapper->tab('Configuration')->with('Add to Menu', array('collapsed' => true, 'class' => 'col-md-4', 'box_class' => 'box box-solid box-danger', 'description' => 'Add to Menu'))->end()->with('Document Father', array('collapsed' => true, 'class' => 'col-md-4', 'box_class' => 'box box-solid box-danger', 'description' => 'Parent/Name'))->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => $this->documentRootPath, 'choice_list' => array(), 'select_root_node' => true, 'required' => false))->add('name', 'text', array('required' => false))->end()->with('Route Father', array('collapsed' => true, 'class' => 'col-md-4', 'box_class' => 'box box-solid box-danger', 'description' => 'Route/URL'))->add('routeChild', 'doctrine_phpcr_odm_tree', array('root_node' => $this->routesRootPath, 'choice_list' => array(), 'select_root_node' => true, 'label' => 'Select Route', 'required' => false))->end()->end();
     } elseif ($isParent && $notMenuAdmin) {
         $formMapper->tab('Configuration')->with('Document Father', array('collapsed' => true, 'class' => 'col-md-4', 'box_class' => 'box box-solid box-danger', 'description' => 'Parent/Name'))->add('parentDocument', 'doctrine_phpcr_odm_tree', array('root_node' => $this->documentRootPath, 'choice_list' => array(), 'select_root_node' => true, 'required' => false))->add('name', 'text', array('required' => false))->end()->end();
     }
     // Configuration, Content and Helpers properties
     $formMapper->tab('Content')->with('Content')->add('title', 'text', array('required' => true))->add('subtitle', 'text', array('required' => false))->add('resume', 'text', array('required' => false))->add('body', 'ckeditor', $this->getCkeditorOptions())->end()->end()->setHelps(array('title' => 'seven_manager.admin.fields.title.helper', 'subtitle' => 'seven_manager.admin.fields.subtitle.helper', 'name' => 'seven_manager.admin.fields.name.helper', 'content' => 'seven_manager.admin.fields.content.helper'));
     // "Globalize" this
     $smEventListener = function (FormEvent $event) use($formMapper) {
         $isParent = $this->getParentFieldDescription() === null;
         // Get form
         $formData = $event->getForm();
         $classImplements = class_implements($this->getClass());
         // To be use to check blockInterface, or not
         // Verify if is a Block or a Parent Document
         if (!$isParent) {
             // Load groups and tabs
             $formTabs = $this->getFormTabs();
             if (!empty($formTabs['default']['groups'])) {
                 // Find tabs and groups
                 $hasPublishable = array_search('form.group_publish_workflow', $formTabs['default']['groups']);
                 $hasLocale = array_search('form.group_general', $formTabs['default']['groups']);
                 // TODO: Create handler remove by form tab or form field all components !!! DRY
                 if (true) {
                     if ($hasPublishable !== false) {
                         $formGroup = $this->getFormGroups();
                         $formTabs = $this->getFormTabs();
                         unset($formGroup['form.group_publish_workflow']);
                         unset($formTabs['default']['groups'][$hasPublishable]);
                         $this->setFormGroups($formGroup);
                         $this->setFormTabs($formTabs);
                     }
                     if ($hasLocale !== false) {
                         $formGroup = $this->getFormGroups();
                         $formTabs = $this->getFormTabs();
                         unset($formGroup['form.group_general']);
                         unset($formTabs['default']['groups'][$hasLocale]);
                         $this->setFormGroups($formGroup);
                         $this->setFormTabs($formTabs);
                     }
                     // Remove locale only if this admin is child
                     if ($formData->has('locale')) {
                         $formData->remove('locale');
                         $formMapper->remove('locale');
                     }
                     // Remove undesired fields
                     if ($formData->has('publish_start_date')) {
                         $formData->remove('publish_start_date')->remove('publish_end_date')->remove('publishable');
                         $formMapper->remove('publish_start_date')->remove('publish_end_date')->remove('publishable');
                     }
                     // If used as child remove locale, locale is set by default
                     // no need extra field in this case
                 }
             } else {
                 // At the end of the future handler remove empty groups to avoid empty tabs
                 // Using get array_values and verify each group
                 $formTabs = $this->getFormTabs();
                 if (empty($formTabs['default']['groups'])) {
                     unset($formTabs['default']);
                     $this->setFormTabs($formTabs);
                 }
             }
         }
     };
     // Add event listener
     $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA, $smEventListener);
 }
开发者ID:7rin0,项目名称:SevenManagerBundle,代码行数:77,代码来源:DefaultAdmin.php


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