當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。