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


PHP FormMapper::getFormBuilder方法代码示例

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


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

 protected function configureFormFields(FormMapper $formMapper)
 {
     $subscriber = new AddMenuTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory());
     $formMapper->getFormBuilder()->addEventSubscriber($subscriber);
     // Getting the container parameters set in the config file that exist
     $menuSettings = $this->getConfigurationPool()->getContainer()->getParameter('menu_settings');
     // Setting up the available actions
     $actionsChoice = $menuSettings['actions'];
     reset($actionsChoice);
     $prefActionsChoice = key($actionsChoice);
     // Setting up the available menu types
     $menuTypeChoice = $menuSettings['menutypes'];
     reset($menuTypeChoice);
     $prefMenuTypeChoice = key($menuTypeChoice);
     // Setting up the available menu groups
     $menuGroupsChoice = $menuSettings['menugroups'];
     reset($menuGroupsChoice);
     $prefMenuGroupsChoice = key($menuGroupsChoice);
     // Setting up the available page types and preffered choice
     $accessLevelChoices = $menuSettings['accessLevel'];
     reset($accessLevelChoices);
     $prefAccessLevelChoices = key($accessLevelChoices);
     // Setting up the available publish states and preffered choice
     $publishStateChoices = $menuSettings['publishState'];
     reset($publishStateChoices);
     $prefPublishStateChoices = key($publishStateChoices);
     $menus = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager')->getRepository('MenuBundle:Menu')->findAll();
     $menusChoice['-'] = 'Hide From Menu';
     $menusChoice['0'] = 'Menu Root';
     foreach ($menus as $menu) {
         $menusChoice[$menu->getId()] = $menu->getTitle() . ' (' . $menu->getMenuGroup() . ')';
     }
     $formMapper->tab('Menu Item Essential Details')->with('Menu Item Essential Details', array('collapsed' => true))->add('title', null, array('label' => 'Title', 'required' => true))->add('menuType', 'choice', array('choices' => $menuTypeChoice, 'preferred_choices' => array($prefMenuTypeChoice), 'label' => 'Menu Item Type', 'required' => true))->add('route', 'choice', array('choices' => $actionsChoice, 'preferred_choices' => array($prefActionsChoice), 'label' => 'Link Action', 'required' => true))->setHelps(array('title' => 'Set the title of the menu item (link copy text)', 'menuType' => 'Set the type of the menu item linked page', 'route' => 'Select the action of the menu item'))->end()->end()->tab('Menu Item Taxonomy')->with('Menu Item Taxonomy', array('collapsed' => true))->add('menuGroup', 'choice', array('choices' => $menuGroupsChoice, 'preferred_choices' => array($prefMenuGroupsChoice), 'label' => 'Menu Group', 'required' => true))->add('parent', 'choice', array('choices' => $menusChoice, 'attr' => array('class' => 'autoCompleteItems autoCompleteMenus', 'data-sonata-select2' => 'false'), 'label' => 'Parent Menu Item', 'required' => false))->add('ordering', null, array('label' => 'Menu Item Order', 'required' => true))->setHelps(array('menuGroup' => 'Set the menu group this menu item belongs to', 'parent' => 'Select the parent menu item', 'ordering' => 'Set the order of the menu item in accordance to the other menu items of the same menu level'))->end()->end()->tab('Menu Item Access Control')->with('Menu Item Access Control', array('collapsed' => true))->add('accessLevel', 'choice', array('choices' => $accessLevelChoices, 'preferred_choices' => array($prefAccessLevelChoices), 'label' => 'Access Level', 'required' => true))->add('publishState', 'choice', array('choices' => $publishStateChoices, 'preferred_choices' => array($prefPublishStateChoices), 'label' => 'Publish State', 'required' => true))->setHelps(array('accessLevel' => 'Set the minimum access level the item is visible to', 'publishState' => 'Set the publish state of this menu item'))->end()->end()->tab('Menu Item Optional Details')->with('Menu Item Optional Details', array('collapsed' => true))->add('menuImage', 'sonata_media_type', array('provider' => 'sonata.media.provider.image', 'context' => 'icons', 'attr' => array('class' => 'imagefield'), 'label' => 'Menu Icon Image', 'required' => false))->setHelps(array('menuImage' => 'Set an image as Menu Icon'))->end();
 }
开发者ID:elom5000,项目名称:BardisCMS,代码行数:34,代码来源:MenuAdmin.php

示例3: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $subscriber = new AddCommentTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory());
     $formMapper->getFormBuilder()->addEventSubscriber($subscriber);
     // Getting the container parameters set in the config file that exist
     $commentSettings = $this->getConfigurationPool()->getContainer()->getParameter('comment_settings');
     // Setting up the available comment types
     $commentTypeChoice = $commentSettings['commenttypes'];
     reset($commentTypeChoice);
     $prefCommentTypeChoice = key($commentTypeChoice);
     $formMapper->with('Comment Details', array('collapsed' => false))->add('title', null, array('label' => 'Comment Title', 'required' => true))->add('username', null, array('label' => 'Username / Name of the commentator', 'required' => true))->add('comment', 'textarea', array('label' => 'Comment', 'required' => true))->add('approved', 'choice', array('choices' => array('0' => 'Hide', '1' => 'Show'), 'preferred_choices' => array('1'), 'label' => 'Approve Comment', 'required' => true))->add('created', 'date', array('widget' => 'single_text', 'format' => 'dd-MM-yyyy', 'attr' => array('class' => 'datepicker'), 'label' => 'Created Date', 'required' => true))->add('commentType', 'choice', array('choices' => $commentTypeChoice, 'preferred_choices' => array($prefCommentTypeChoice), 'label' => 'Comment Type', 'required' => true))->setHelps(array('title' => 'Set the title of the comment', 'commentType' => 'Set the page type that this applies to', 'username' => 'Set username/name of the userer that commented', 'created' => 'The comment creation date', 'comment' => 'The contents of the comment', 'approved' => 'Aproval Status'))->end();
 }
开发者ID:elom5000,项目名称:BardisCMS,代码行数:12,代码来源:CommentAdmin.php

示例4: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     if ($this->getSubject()) {
         $classType = $this->getSubject()->getClassType();
     } else {
         $classType = $this->getRequest()->get('classType');
     }
     /** @var LayoutBlockFormListener $listener */
     $listener = $this->getContainer()->get('networking_init_cms.layout_block_form_listener');
     $listener->setAdmin($this);
     $listener->setContentType($classType);
     $formMapper->getFormBuilder()->addEventSubscriber($listener);
     $pageManager = $this->getContainer()->get('networking_init_cms.page_manager');
     $transformer = new PageToNumberTransformer($pageManager);
     $formMapper->add('name', 'text')->add('zone', 'hidden')->add($formMapper->getFormBuilder()->create('page', 'hidden')->addModelTransformer($transformer), 'hidden')->add('classType', 'hidden')->add('sortOrder', 'hidden');
 }
开发者ID:ajalovec,项目名称:init-cms-bundle,代码行数:19,代码来源:LayoutBlockAdmin.php

示例5: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $emIndustry = $this->modelManager->getEntityManager('Application\\AlexL\\Sonata\\ResumeBundle\\Entity\\Industry');
     $query = $emIndustry->getRepository('AlexLSonataResumeBundle:Industry')->getFindAllParentsQueryBuilder();
     $formMapper->add('company')->add('industry', 'sonata_type_model', ['attr' => ['onchange' => 'submit()'], 'query' => $query, 'required' => false])->add('subIndustry', 'sonata_type_model', ['choices' => [], 'required' => false])->add('workforce', 'sonata_type_model', ['required' => false])->add('jobTitle')->add('department', 'sonata_type_model', ['required' => false])->add('status', 'sonata_type_model', ['required' => false])->add('start', 'date', ['empty_value' => ['year' => 'Year', 'month' => 'Month', 'day' => 'Day']])->add('end', 'date', ['empty_value' => ['year' => 'Year', 'month' => 'Month', 'day' => 'Day']])->add('stillWork', null, ['label' => 'I still work there', 'required' => false])->add('description', 'ckeditor', ['help' => 'List you duties and responsibilities', 'required' => false])->add('managedTeam', null, ['label' => ' I managed a team', 'required' => false])->add('enabled', null, ['required' => false]);
     $builder = $formMapper->getFormBuilder();
     $factory = $builder->getFormFactory();
     $subject = $this->getSubject();
     $modelManager = $this->getModelManager();
     $formModifier = function (FormInterface $form, Industry $industry) use($emIndustry, $factory, $modelManager) {
         $query = $emIndustry->getRepository('AlexLSonataResumeBundle:Industry')->getFindChildrenByParentQueryBuilder($industry);
         $form->add($factory->createNamed('subIndustry', 'sonata_type_model', null, ['class' => 'Application\\AlexL\\Sonata\\ResumeBundle\\Entity\\Industry', 'query' => $query, 'required' => false, 'model_manager' => $modelManager, 'auto_initialize' => false]));
     };
     $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier, $subject) {
         $form = $event->getForm();
         if (!is_null($subject->getIndustry())) {
             $formModifier($form, $subject->getIndustry());
         }
     });
     $builder->get('industry')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use($formModifier, $subject) {
         $form = $event->getForm();
         if (!is_null($subject->getIndustry())) {
             $formModifier($form, $subject->getIndustry());
         }
     });
 }
开发者ID:AlexLStudio,项目名称:alexlstudio,代码行数:29,代码来源:WorkExperienceAdmin.php

示例6: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName());
     $formMapper->add('productCode')->add('price')->add('quantity')->add('product');
     if (!$nested) {
         $formMapper->add('itemorder')->add('description');
     }
 }
开发者ID:softlogo,项目名称:shop-bundle,代码行数:11,代码来源:BasketItemAdmin.php

示例7: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->with("Рассказ");
     if ($this->getSubject()->getId()) {
         $formMapper->add('storyOrder', 'number', ['label' => "Порядок отображения"]);
     }
     $formMapper->add("publicationDate", "sonata_type_date_picker", ['label' => "Дата публикации", 'format' => 'dd-MM-yyyy'])->add("title", "text", ["label" => "Название рассказа"])->add('text', 'sonata_formatter_type', ['label' => "Содержание рассказа", 'required' => TRUE, 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'textFormatter', 'source_field' => 'rawText', 'ckeditor_context' => 'base_config', 'listener' => TRUE, 'target_field' => 'text'])->add('storyCategory', 'entity', ['class' => 'AppBundle\\Entity\\StoryCategory', 'label' => "Категория рассказа"])->add("views", "number", ['required' => FALSE, "label" => "Просмотры"])->add('isFreeForAll', 'checkbox', ['required' => FALSE, 'label' => "Доступен для всех"])->end()->with("Локализации")->add("translations", "a2lix_translations_gedmo", ["label" => "Управление локализациями", "translatable_class" => 'AppBundle\\Entity\\Story', "required" => FALSE, "fields" => ["title" => ["locale_options" => ["en" => ["label" => "Story title"]]], "text" => ["locale_options" => ["en" => ["label" => "Content", 'field_type' => 'ckeditor', 'config_name' => 'base_config']]]]])->end()->with("Рецензии")->add("reviews", "sonata_type_collection", ['required' => FALSE, 'by_reference' => FALSE], ['multiple' => TRUE, 'edit' => 'inline', 'inline' => 'table']);
 }
开发者ID:Kid-Binary,项目名称:KamillNurakhmetov,代码行数:8,代码来源:StoryAdmin.php

示例8: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName());
     $formMapper->add('name');
     if (!$nested) {
         $formMapper->add('description')->add('isMain');
     }
     $formMapper->add('value')->add('itemorder')->add('dictionaries', 'sonata_type_collection', array('label' => 'Dictionaries', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'));
 }
开发者ID:softlogo,项目名称:cms-bundle,代码行数:12,代码来源:DictionaryAdmin.php

示例9: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     // Getting the container parameters set in the config file that exist
     $contentblockSettings = $this->getConfigurationPool()->getContainer()->getParameter('contentblock_settings');
     // Setting up the available content types and preffered choice
     $contentTypeChoices = $contentblockSettings['contenttypes'];
     reset($contentTypeChoices);
     $prefContentTypeChoice = key($contentTypeChoices);
     // Setting up the available content sizes and preffered choice
     $sizeclassChoices = $contentblockSettings['contentsizes'];
     reset($sizeclassChoices);
     $prefSizeclassChoice = key($sizeclassChoices);
     // Setting up the available media sizes
     $mediasizes = $contentblockSettings['mediasizes'];
     $subscriber = new AddContentTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory(), $mediasizes);
     $formMapper->getFormBuilder()->addEventSubscriber($subscriber);
     $formMapper->with('Content Block Details', array('collapsed' => false))->add('title', 'text', array('label' => 'Content Block Title', 'required' => true))->add('availability', 'choice', array('choices' => array('page' => 'One Page Only', 'global' => 'All Pages'), 'preferred_choices' => array('0'), 'label' => 'Available to', 'required' => true))->add('publishedState', 'choice', array('choices' => array('0' => 'Unpublished', '1' => 'Published'), 'preferred_choices' => array('1'), 'label' => 'Publish State', 'required' => true))->add('showTitle', 'choice', array('choices' => array('0' => 'Hide Title', '1' => 'Show Title'), 'preferred_choices' => array('1'), 'label' => 'Title Display State', 'required' => true))->add('ordering', 'hidden', array('attr' => array('class' => 'orderField'), 'label' => 'Content Block Ordering', 'required' => true))->add('className', 'text', array('label' => 'CSS Class', 'required' => false))->add('idName', 'text', array('label' => 'CSS Id', 'required' => false))->add('sizeclass', 'choice', array('choices' => $sizeclassChoices, 'preferred_choices' => array($prefSizeclassChoice), 'label' => 'Content Block Width', 'required' => true))->add('contentType', 'choice', array('choices' => $contentTypeChoices, 'preferred_choices' => array($prefContentTypeChoice), 'label' => 'Content Type', 'required' => true))->setHelps(array('title' => 'Set the title of the content block'))->end();
 }
开发者ID:elom5000,项目名称:BardisCMS,代码行数:18,代码来源:ContentBlockAdmin.php

示例10: configureFormFields

 /**
  * {@inheritdoc}
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     /*
      d('$formMapper');
      d('$formMapper');
      d($formMapper);
     */
     $formMapper->with('Work', array('class' => 'col-md-8'))->add('author', 'sonata_type_model_list')->add('title')->add('slug', null, array('required' => true))->add('link', 'url', array('required' => false))->add('abstract', null, array('attr' => array('rows' => 5)))->add('content', 'sonata_formatter_type', array('event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'contentFormatter', 'source_field' => 'rawContent', 'source_field_options' => array('horizontal_input_wrapper_class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'col-lg-12' : '', 'attr' => array('class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'span10 col-sm-10 col-md-10' : '', 'rows' => 20)), 'ckeditor_context' => 'portfolio', 'target_field' => 'content', 'listener' => true))->end()->with('Status', array('class' => 'col-md-4'))->add('enabled', null, array('required' => false))->add('image', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'portfolio')))->add('gallery', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'portfolio')))->add('publicationDateStart', 'sonata_type_datetime_picker', array('dp_side_by_side' => true))->end()->with('Classification', array('class' => 'col-md-4'))->add('tags', 'sonata_type_model_autocomplete', array('property' => 'name', 'multiple' => 'true', 'required' => false))->add('collection', 'sonata_type_model_list', array('required' => false))->end();
 }
开发者ID:NadirZenith,项目名称:PortfolioBundle,代码行数:12,代码来源:WorkAdmin.php

示例11: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->add('title')->add('description')->add('tokens', 'text', array('label' => 'Class Tokens', 'required' => false))->add('scheduleColor', 'tsk_class_schedule_color_type');
     // This subscriber is responsible for dynamically adding
     // the classTypeCredits interface
     $entityManager = $this->modelManager->getEntityManager('TSK\\ClassBundle\\Entity\\ClassType');
     $builder = $formMapper->getFormBuilder();
     $subscriber = new DrawClassTypeCredits($builder->getFormFactory(), $entityManager, $this->request->getSession()->get($this->orgSessionKey));
     $builder->addEventSubscriber($subscriber);
 }
开发者ID:sgh1986915,项目名称:symfony-tsk,代码行数:10,代码来源:ClassesAdmin.php

示例12: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     //$conf=new CMSConfiguration();
     //$conf=$this->container->get('cms_conf');
     $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName());
     $formMapper->add('name')->add('itemorder', 'text', array('label' => 'Item Order'))->add('anchor', 'text', array('label' => 'Anchor'))->add('title', 'text', array('label' => 'Page Title'))->add('description', 'text', array('label' => 'Page Description'))->add('keywords', 'text', array('label' => 'Page Keywords'))->add('type', 'choice', array('multiple' => false, 'choices' => $this->conf->getKeys('page_types')));
     if (!$nested) {
         $formMapper->add('media', 'sonata_type_model_list', array('required' => false), array())->add('site')->add('page')->add('href', 'text', array('label' => 'Href', 'required' => false))->add('isMenu')->add('priority')->add('isActive')->add('articles', 'sonata_type_collection', array('label' => 'Articles', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard'))->add('pages', 'sonata_type_collection', array('label' => 'Pages', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('pageSections', 'sonata_type_collection', array('label' => 'Sekcje', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('language')->add('contents', 'sonata_type_collection', array('label' => 'Wersje językowe', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard'));
     }
 }
开发者ID:softlogo,项目名称:cms-bundle,代码行数:10,代码来源:PageAdmin.php

示例13: end

 /**
  * Закончить задание содержания мультиязычной
  * вкладки и передать результат в мапер формы
  * @desc Метод повторяет поведение класса FormMapper
  * @return FormMapper
  */
 public function end()
 {
     $eventSubscriber = new AddTranslationFieldSubscriber($this->em, $this->localeManager, $this->mappingFactory, $this->fileStorage);
     $this->formMapper->getFormBuilder()->addEventSubscriber($eventSubscriber);
     $firstTab = true;
     $locales = $this->localeManager->getActiveList();
     $administrator = $this->getTokenStorage()->getToken()->getUser();
     if ($administrator instanceof Administrator) {
         usort($locales, [$administrator, 'sortLocales']);
     }
     foreach ($locales as $localeData) {
         $tabName = $localeData->getName();
         if (strlen($this->tabName) > 0) {
             $tabName = str_replace('%locale_name%', $localeData->getName(), $this->tabName);
         }
         $tabOptions = [];
         if ($this->isDisabledByAdministratorLocales($localeData->getAlias())) {
             $tabOptions = ['class' => 'disabled'];
         }
         $this->formMapper->with($tabName, $tabOptions);
         foreach ($this->fields as $fieldData) {
             if (!$firstTab && (!isset($fieldData['options']['translatable']) || !$fieldData['options']['translatable'])) {
                 continue;
             }
             $fieldName = $fieldData['name'];
             if (isset($fieldData['options']['translatable'])) {
                 if ($fieldData['options']['translatable']) {
                     $fieldName = 'translation___' . $fieldData['name'] . '___' . $localeData->getAlias();
                     $fieldData['options']['mapped'] = false;
                     if (isset($fieldData['options']['locale'])) {
                         $fieldData['options']['locale'] = $localeData->getAlias();
                     }
                     $fieldData['options']['disabled'] = $this->isDisabled($localeData->getAlias(), $fieldData['options']);
                     if ($localeData->getAlias() != $this->localeManager->getDefaultLocaleAlias()) {
                         //убираем обязательность полей для языков
                         $fieldData['options']['required'] = false;
                         if (!empty($fieldData['options']['inner_constraints'])) {
                             foreach ($fieldData['options']['inner_constraints'] as $key => $value) {
                                 if ($value instanceof FileNotBlank) {
                                     unset($fieldData['options']['inner_constraints'][$key]);
                                 }
                             }
                         }
                     }
                 }
                 unset($fieldData['options']['translatable']);
             }
             $this->formMapper->add($fieldName, $fieldData['type'], $fieldData['options'], $fieldData['fieldDescriptionOptions']);
         }
         $this->formMapper->end();
         $firstTab = false;
     }
     return $this->formMapper;
 }
开发者ID:octava,项目名称:cms,代码行数:60,代码来源:TranslationMapper.php

示例14: configureFormFields

 /**
  * @param FormMapper $formMapper
  */
 protected function configureFormFields(FormMapper $formMapper)
 {
     $formMapper->add('product', null, array('read_only' => true, 'disabled' => true))->add('process', null, array('read_only' => true, 'disabled' => true))->add('employee', null, array('read_only' => true, 'disabled' => true))->add('startDateTime', 'sonata_type_datetime_picker', array('required' => false, 'format' => 'dd/MM/yyyy HH:mm'))->add('endDateTime', 'sonata_type_datetime_picker', array('required' => false, 'format' => 'dd/MM/yyyy HH:mm'))->add('timeConsuming', null, array('required' => false, 'label' => 'Total time spent (minutes)', 'disabled' => true))->add('finishedFlag', 'choice', array('choices' => array(0 => 'No', 1 => 'Yes'), 'expanded' => true, 'multiple' => false, 'required' => true, 'label' => 'Finished?'));
     $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
         $object = $this->getSubject($event->getData());
         $form = $event->getForm();
         if (!$object || null === $object->getId()) {
             $form->add('product', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose product----'))->add('process', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose process----'))->add('employee', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose employee----'));
         }
     });
 }
开发者ID:kurmin,项目名称:ts_project,代码行数:14,代码来源:ProductProcessTimeAdmin.php

示例15: configureFormFields

 protected function configureFormFields(FormMapper $formMapper)
 {
     $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName());
     if (!$nested) {
         $formMapper->add('category', 'entity', array('class' => 'Softlogo\\ShopBundle\\Entity\\Category', 'label' => 'Kategoria'));
     }
     $formMapper->add('name', 'text', array('label' => 'Nazwa podkategorii'));
     //->add('description', 'ckeditor', array('label' => 'Opis podkategorii'))
     if (!$nested) {
         $formMapper->with('Produkty', array('collapsed' => true))->add('products', 'sonata_type_collection', array('label' => 'Produkty', 'by_reference' => false, 'required' => false, 'type_options' => array('delete' => true)), array('edit' => 'inline', 'inline' => 'standard', 'allow_delete' => true));
     }
 }
开发者ID:softlogo,项目名称:cms-bundle,代码行数:12,代码来源:SubcategoryAdmin.php


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