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


PHP FormBuilderInterface::getParent方法代码示例

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


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

示例1: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $help = $options['help'];
     if ($help === null && $builder->hasParent()) {
         $parentClass = $builder->getParent()->getOption('data_class');
         $fieldName = $builder->getName();
         if ($parentClass !== null) {
             $reflector = new ReflectionProperty($parentClass, $fieldName);
             $annot = $this->reader->getPropertyAnnotation($reflector, 'Tg\\OkoaBundle\\Form\\Annotation\\Help');
             if ($annot !== null) {
                 $help = $annot->value;
             }
         }
     }
     $builder->setAttribute('help', $help);
 }
开发者ID:tweedegolf,项目名称:okoabundle,代码行数:19,代码来源:HelpTypeExtension.php

示例2: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $format_date = $this->_container->get('pi_app_admin.twig.extension.tool')->getDatePatternByLocalFunction($this->_locale);
     $id_media = NULL;
     $id_tags = NULL;
     // get the id of media
     if ($builder->getParent()->getData()->getBlocGeneral() instanceof \Cmf\ContentBundle\Entity\BlocGeneral && $builder->getParent()->getData()->getBlocGeneral()->getMedia() instanceof \Sfynx\MediaBundle\Entity\Mediatheque) {
         $id_media = $builder->getParent()->getData()->getBlocGeneral()->getMedia()->getId();
     }
     if (isset($_POST['plugins_contentbundle_articletype']['blocgeneral']['media'])) {
         $id_media = $_POST['plugins_contentbundle_articletype']['blocgeneral']['media'];
     } elseif (isset($_POST['plugins_contentbundle_pagetype']['blocgeneral']['media'])) {
         $id_media = $_POST['plugins_contentbundle_pagetype']['blocgeneral']['media'];
     } elseif (isset($_POST['plugins_contentbundle_testtype']['blocgeneral']['media'])) {
         $id_media = $_POST['plugins_contentbundle_testtype']['blocgeneral']['media'];
     } elseif (isset($_POST['plugins_contentbundle_diaporamatype']['blocgeneral']['media'])) {
         $id_media = $_POST['plugins_contentbundle_diaporamatype']['blocgeneral']['media'];
     }
     // get the ids of tag
     if ($builder->getParent()->getData()->getBlocGeneral() instanceof \Cmf\ContentBundle\Entity\BlocGeneral && $builder->getParent()->getData()->getBlocGeneral()->getTag()->count() >= 1) {
         $entities = $builder->getParent()->getData()->getBlocGeneral()->getTag()->toArray();
         foreach ($entities as $k => $v) {
             $id_tags[] = $v->getId();
         }
     }
     if (isset($_POST['plugins_contentbundle_articletype']['blocgeneral']['tag'])) {
         $id_tags = $_POST['plugins_contentbundle_articletype']['blocgeneral']['tag'];
     } elseif (isset($_POST['plugins_contentbundle_pagetype']['blocgeneral']['tag'])) {
         $id_tags = $_POST['plugins_contentbundle_pagetype']['blocgeneral']['tag'];
     } elseif (isset($_POST['plugins_contentbundle_testtype']['blocgeneral']['tag'])) {
         $id_tags = $_POST['plugins_contentbundle_testtype']['blocgeneral']['tag'];
     } elseif (isset($_POST['plugins_contentbundle_diaporamatype']['blocgeneral']['tag'])) {
         $id_tags = $_POST['plugins_contentbundle_diaporamatype']['blocgeneral']['tag'];
     }
     $builder->add('title', 'text', array('label' => "pi.form.label.field.title", "label_attr" => array("class" => ""), 'required' => true, 'constraints' => array(new Constraints\NotBlank())))->add('enabled', 'hidden', array('data' => true))->add('author', 'text', array('label' => "Auteur", "label_attr" => array("class" => ""), 'required' => true))->add('published_at', 'date', array('widget' => 'single_text', 'input' => 'datetime', 'format' => $format_date, 'required' => true, "attr" => array("class" => "pi_datepicker"), 'label' => 'Date de mise en ligne'))->add('archive_at', 'date', array('widget' => 'single_text', 'input' => 'datetime', 'format' => $format_date, 'required' => false, "attr" => array("class" => "pi_datepicker"), 'label' => 'Date d\'expiration'))->add('created_at', 'date', array('read_only' => true, 'widget' => 'single_text', 'input' => 'datetime', 'format' => $format_date, 'required' => true, 'label' => 'Date de création'))->add('updated_at', null, array('attr' => array('style' => 'display:none;'), "label_attr" => array("style" => 'display:none;')))->add('descriptif', 'textarea', array('label' => "Description courte", "label_attr" => array("class" => "text_collection"), "attr" => array("class" => "pi_editor_easy"), 'required' => true))->add('subrub', 'entity', array('class' => 'PluginsContentBundle:Rub', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('k')->select('k')->andWhere('k.parent IS NOT NULL')->orderBy('k.id', 'ASC');
     }, 'empty_value' => 'Choisir une sous-rubrique', 'multiple' => false, 'group_by' => "parent.title", 'required' => true, 'label' => "Rubrique principale", 'constraints' => array(), "label_attr" => array("class" => "classement_collection"), "attr" => array("class" => "pi_simpleselect")))->add('rub', 'entity', array('class' => 'PluginsContentBundle:Rub', 'query_builder' => function (EntityRepository $er) {
         return $er->createQueryBuilder('k')->select('k')->andWhere('k.parent IS NOT NULL')->orderBy('k.id', 'ASC');
     }, 'empty_value' => 'Choisir une sous-rubrique', 'multiple' => true, 'group_by' => "parent.title", 'required' => false, 'label' => "Rubriques associées", "label_attr" => array("class" => "classement_collection"), "attr" => array("class" => "pi_multiselect")))->add('tag', 'entity', array('class' => 'PluginsContentBundle:Tag', 'query_builder' => function (EntityRepository $er) use($id_tags) {
         $translatableListener = $this->_container->get('gedmo.listener.translatable');
         $translatableListener->setTranslationFallback(true);
         return $er->createQueryBuilder('a')->select('a')->where("a.id IN (:id)")->andWhere('a.enabled = 1')->setParameter('id', $id_tags)->orderBy('a.id', 'ASC');
     }, 'empty_value' => 'pi.form.label.select.choose.tag', 'label' => "Tag", 'multiple' => true, 'required' => false, 'constraints' => array(new Constraints\NotBlank()), "label_attr" => array("class" => "classement_collection"), "attr" => array("class" => "pi_multiselect ajaxselect", "data-url" => $this->_container->get('bootstrap.RouteTranslator.factory')->getRoute("admin_content_tag_selectentity_ajax"), "data-max" => 19), 'widget_suffix' => '<a class="button-ui-mediatheque button-ui-dialog"
          				title="Ajouter un tag à la sélection"
          				data-title="Tags"
          				data-href="' . $this->_container->get('bootstrap.RouteTranslator.factory')->getRoute("admin_content_tag_new", array("NoLayout" => "false", "category" => '')) . '"
          				data-selectid="#piapp_gedmobundle_tagtype_id"
          				data-selecttitle="#piapp_gedmobundle_tagtype_title"
          				data-insertid="#' . str_replace('_blocgeneral_media', '_blocgeneral_tag', $this->_insertid) . '"
          				data-inserttype="multiselect"
          				></a>'))->add('metaKeywords', 'text', array('label' => "metaKeywords", "label_attr" => array("class" => "meta_definition"), 'required' => false))->add('metaDescription', 'textarea', array("label" => "pi.form.label.field.meta_description", "label_attr" => array("class" => "meta_definition"), 'required' => false))->add('media', 'entity', array('class' => 'PiAppGedmoBundle:Media', 'query_builder' => function (EntityRepository $er) use($id_media) {
         $translatableListener = $this->_container->get('gedmo.listener.translatable');
         $translatableListener->setTranslationFallback(true);
         return $er->createQueryBuilder('a')->select('a')->where("a.id IN (:id)")->setParameter('id', $id_media);
     }, 'empty_value' => 'pi.form.label.select.choose.media', 'label' => "Media", 'multiple' => false, 'required' => false, "label_attr" => array("class" => 'bg_image_collection'), "attr" => array("class" => "pi_simpleselect ajaxselect", "data-url" => $this->_container->get('bootstrap.RouteTranslator.factory')->getRoute("admin_gedmo_media_selectentity_ajax", array('type' => 'image')), "data-max" => 50), 'widget_suffix' => '<a class="button-ui-mediatheque button-ui-dialog"
          				title="Ajouter une image à la médiatheque"
          				data-title="Mediatheque"
          				data-href="' . $this->_container->get('bootstrap.RouteTranslator.factory')->getRoute("admin_gedmo_media_new", array("NoLayout" => "false", "category" => '', 'status' => 'image')) . '"
          				data-selectid="#piapp_gedmobundle_mediatype_id"
          				data-selecttitle="#piapp_gedmobundle_mediatype_title"
          				data-insertid="#' . $this->_insertid . '"
          				data-inserttype="multiselect"
          				></a>'));
 }
开发者ID:pigroupe,项目名称:CmfContentBundle,代码行数:64,代码来源:BlocGeneralType.php


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