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


PHP FormInterface::getParent方法代码示例

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


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

示例1: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['object'] = $form->getParent()->getData();
     if ($options['download_link'] && $view->vars['object']) {
         $view->vars['download_uri'] = $this->storage->resolveUri($form->getParent()->getData(), $form->getName());
     }
 }
开发者ID:j0ssGZ,项目名称:VichUploaderBundle,代码行数:10,代码来源:VichFileType.php

示例2: getErrorFormLabel

 /**
  * Returns first label for field with error
  *
  * @param  FormInterface $form
  * @return array
  */
 protected function getErrorFormLabel(FormInterface $form)
 {
     $vars = $form->createView()->vars;
     $label = $vars['label'];
     $translationDomain = $vars['translation_domain'];
     $result = array('label' => $label, 'domain' => $translationDomain);
     if (empty($label)) {
         if ($form->getParent() !== null) {
             $result = $this->getErrorFormLabel($form->getParent());
         }
     }
     return $result;
 }
开发者ID:auamarto,项目名称:crud-bundle,代码行数:19,代码来源:FormErrorHandler.php

示例3: chooseGroups

 /**
  * {@inheritdoc}
  */
 public function chooseGroups(FormInterface $form)
 {
     $dayPhoneData = $form->get('dayPhone')->getData();
     $eveningPhoneData = $form->get('eveningPhone')->getData();
     $emailData = $form->get('email')->getData();
     // All other fields are validated through the Default validation group
     $validation_groups = array('Default');
     // todo: is there an apprpoach that does not require the sdk models?
     /** @var ReferencingApplication $application */
     $application = $form->getParent()->getData();
     if ($application instanceof ReferencingApplication) {
         // If Optimum product, require at least one contact detail must be given
         if (19 == $application->getProductId()) {
             if (empty($dayPhoneData) && empty($eveningPhoneData) && empty($emailData)) {
                 $validation_groups[] = 'dayphone';
                 $validation_groups[] = 'eveningphone';
                 $validation_groups[] = 'email';
             }
         }
         // If no day phone, enforce evening
         if (empty($dayPhoneData)) {
             $validation_groups[] = 'eveningphone';
         }
         // If no evening phone, enforce day
         if (empty($eveningPhoneData)) {
             if ($k = array_search('eveningphone', $validation_groups)) {
                 unset($validation_groups[$k]);
             }
             $validation_groups[] = 'dayphone';
         }
         return $validation_groups;
     }
     return array('Default');
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:37,代码来源:LettingRefereeValidationGroupSelector.php

示例4: finishView

 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $permissionForm = $form->getParent();
     if (!$permissionForm) {
         return;
     }
     $permissionsForm = $permissionForm->getParent();
     if (!$permissionsForm) {
         return;
     }
     $privilegeForm = $permissionsForm->getParent();
     if (!$privilegeForm) {
         return;
     }
     $privilegesForm = $privilegeForm->getParent();
     if (!$privilegesForm) {
         return;
     }
     $roleForm = $privilegesForm->getParent();
     if (!$roleForm) {
         return;
     }
     if (in_array($roleForm->getConfig()->getType()->getName(), [AccountUserRoleType::NAME, FrontendAccountUserRoleType::NAME])) {
         //uses on edit page for rendering preloaded string (role permission name)
         $view->vars['translation_prefix'] = $this->roleTranslationPrefixResolver->getPrefix();
     }
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:30,代码来源:AclAccessLevelSelectorExtension.php

示例5: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $vars = ['configs' => $options['configs']];
     if ($form->getData()) {
         $data = $form->getParent()->getData();
         $fieldConfig = $this->cm->getProvider('extend')->getConfig($data, $form->getName());
         if ($form->getData()) {
             /** @var ConverterInterface|EntitySelectHandler $converter */
             $converter = $options['converter'];
             $result = [];
             if ($converter instanceof EntitySelectHandler) {
                 $converter->initForEntity($fieldConfig->getId()->getClassName(), $fieldConfig->get('target_field'));
             }
             if (isset($options['configs']['multiple']) && $options['configs']['multiple']) {
                 foreach ($form->getData() as $item) {
                     $result[] = $converter->convertItem($item);
                 }
             } else {
                 $result[] = $converter->convertItem($form->getData());
             }
             $vars['attr'] = ['data-selected-data' => json_encode($result)];
         }
     }
     $view->vars = array_replace_recursive($view->vars, $vars);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:28,代码来源:EntitySelectType.php

示例6: finishView

 /**
  * {@inheritDoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $formParent = $form->getParent();
     if (!$formParent) {
         return;
     }
     /* @var $productUnitHolder ProductUnitHolderInterface */
     $productUnitHolder = $formParent->getData();
     if (!$productUnitHolder) {
         return;
     }
     $product = $productUnitHolder->getProductHolder()->getProduct();
     $choices = $this->getProductUnits($product);
     $productUnit = $productUnitHolder->getProductUnit();
     if (!$productUnit || $product && !in_array($productUnit, $choices, true)) {
         $emptyValueTitle = $this->translator->trans($this->options['empty_label'], ['{title}' => $productUnitHolder->getProductUnitCode()]);
         $view->vars['empty_value'] = $emptyValueTitle;
     }
     $choices = $this->productUnitFormatter->formatChoices($choices, $options['compact']);
     $choicesViews = [];
     foreach ($choices as $key => $value) {
         $choicesViews[] = new ChoiceView($value, $key, $value);
     }
     $view->vars['choices'] = $choicesViews;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:28,代码来源:ProductUnitRemovedSelectionType.php

示例7: getRootFormCascadeOption

 /**
  * Navigates to the Root form to define if cascading should be done.
  *
  * @param FormInterface $form
  * @return boolean
  */
 public function getRootFormCascadeOption(FormInterface $form)
 {
     if (!$form->isRoot()) {
         return $this->getRootFormCascadeOption($form->getParent());
     }
     return $form->getConfig()->getOption('cascade_filter', false);
 }
开发者ID:rdohms,项目名称:dms-filter-bundle,代码行数:13,代码来源:DelegatingFilterListener.php

示例8: buildView

 /**
  * Pass the image URL to the view.
  *
  * @param FormView      $view
  * @param FormInterface $form
  * @param array         $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $data = $form->getParent()->getData();
     if ($data instanceof ContentSpec) {
         $tmpName = explode('_', $form->getName());
         if (count($tmpName) === 3) {
             $currentFile = null;
             foreach ($data->getTranslations() as $tr) {
                 if ($tr->getLocale() == $tmpName[1] && ($tr->getField() == 'content' || $tr->getField() == 'data')) {
                     $contents = json_decode($tr->getContent(), true);
                     if (isset($contents[$tmpName[2]])) {
                         $currentFile = $contents[$tmpName[2]];
                     }
                 }
             }
         } else {
             $currentFile = $data->getInContent($form->getName());
             if (!$currentFile) {
                 $currentFile = $data->getInData($form->getName());
             }
         }
         if ($currentFile) {
             $currentFileWeb = $this->nyrocms->getHandler($data->getContentHandler())->getUploadDir() . '/' . $currentFile;
             $view->vars['currentFile'] = $currentFileWeb;
             $view->vars['showDelete'] = $options['showDelete'] && is_string($options['showDelete']) ? $options['showDelete'] : false;
         }
     }
 }
开发者ID:nyroDev,项目名称:NyroCmsBundle,代码行数:35,代码来源:FileTypeExtension.php

示例9: disableField

 /**
  * Disable a field after the form has been created
  *
  * @param FormInterface $field
  */
 protected function disableField(FormInterface $field)
 {
     $config = $field->getConfig();
     $options = $config->getOptions();
     $options['disabled'] = true;
     $field->getParent()->add($field->getName(), $config->getType()->getInnerType(), $options);
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:12,代码来源:DisableFamilyFieldsSubscriber.php

示例10: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     //parent::buildView($view, $form, $options);
     $entity = $form->getParent()->getData();
     $property_name = $view->vars['name'];
     $this->defaults = array_merge($this->defaults, $options);
     // entity info
     $entity_info = $this->container->get('itf.admin_helper')->getEntityInfo(get_class($entity));
     $fk_entity_info = $this->container->get('itf.admin_helper')->getEntityInfo($this->defaults['data_class']);
     $this->defaults['fn_entity'] = $entity_info['entity_short'];
     $this->defaults['fn_bundle'] = $entity_info['bundle_short'];
     $this->defaults['fn_property'] = $property_name;
     $this->defaults['fn_fk_entity'] = $fk_entity_info['entity_short'];
     $this->defaults['fn_fk_bundle'] = $fk_entity_info['bundle_short'];
     // extract constraints
     $validator = $this->container->get('validator');
     $metadata = $validator->getMetadataFor($fk_entity_info['entity_fq']);
     if (isset($metadata->properties[$this->defaults['fn_entity_property']])) {
         $this->extractConstraints($metadata->properties[$this->defaults['fn_entity_property']]);
     }
     // set id
     if (method_exists($entity, 'getId')) {
         $this->defaults['fn_entity_id'] = (int) $entity->getId();
     }
     $view->vars = array_merge($view->vars, $this->defaults);
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:26,代码来源:FineuploaderMultipleType.php

示例11: finishView

 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $permissionForm = $form->getParent();
     if (!$permissionForm) {
         return;
     }
     $permissionsForm = $permissionForm->getParent();
     if (!$permissionsForm) {
         return;
     }
     $privilegeForm = $permissionsForm->getParent();
     if (!$privilegeForm) {
         return;
     }
     $privilegesForm = $privilegeForm->getParent();
     if (!$privilegesForm) {
         return;
     }
     $roleForm = $privilegesForm->getParent();
     if (!$roleForm) {
         return;
     }
     if ($roleForm->getConfig()->getType()->getName() === AccountUserRoleType::NAME) {
         $view->vars['translation_prefix'] = 'orob2b.customer.security.access-level.';
     }
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:29,代码来源:AclAccessLevelSelectorExtension.php

示例12: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $options['expanded'] = false;
     // only select can be dynamic
     if ($options['source_field']) {
         $value = $form->getParent()[$options['source_field']]->getData();
         if (is_object($value)) {
             $value = $value->getId();
         }
         $view->vars['source_field'] = $options['source_field'];
         $completeChoices = array();
         foreach ($options['choices'] as $key => $val) {
             $completeChoices[$key] = array();
             foreach ($val as $k => $v) {
                 $completeChoices[$key][] = array('id' => $k, 'text' => $v);
             }
         }
         $view->vars['complete_choices'] = $completeChoices;
         $choices = array();
         if (isset($options['choices'][$value])) {
             $choices = $options['choices'][$value];
         }
         $options['choice_list'] = new SimpleChoiceList($choices);
     }
     parent::buildView($view, $form, $options);
 }
开发者ID:symbio,项目名称:orangegate4-admin-bundle,代码行数:26,代码来源:DynamicChoiceType.php

示例13: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $parentData = $form->getParent()->getData();
     $accountId = null;
     if ($parentData instanceof Account) {
         $accountId = $parentData->getId();
     }
     $view->vars['configs']['accountId'] = $accountId;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:12,代码来源:ParentAccountSelectType.php

示例14: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $parentData = $form->getParent()->getData();
     $parentId = null;
     if ($parentData instanceof Customer) {
         $parentId = $parentData->getId();
     }
     $view->vars['parent_id'] = $parentId;
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:12,代码来源:ParentCustomerSelectType.php

示例15: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $parent = $form->getParent()->getParent()->getParent();
     $parentData = $parent->getData();
     if ($parentData instanceof AclPrivilege) {
         $view->vars['identity'] = $parentData->getIdentity()->getId();
         $view->vars['level_label'] = AccessLevel::getAccessLevelName($form->getData());
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:AclAccessLevelSelectorType.php


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