當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormEvent::getName方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\FormEvent::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormEvent::getName方法的具體用法?PHP FormEvent::getName怎麽用?PHP FormEvent::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\FormEvent的用法示例。


在下文中一共展示了FormEvent::getName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setData

 public function setData($data)
 {
     if ($this->event->getName() == FormEvents::PRE_SUBMIT) {
         $this->event->setData($data);
     } else {
         trigger_error(__CLASS__ . "::" . __FUNCTION__ . " can only be called in BoltFormsEvents::PRE_SUBMIT", E_USER_ERROR);
     }
 }
開發者ID:rossriley,項目名稱:bolt-extension-boltforms,代碼行數:8,代碼來源:BoltFormsEvent.php

示例2: setData

 public function setData($data)
 {
     if ($this->event->getName() === FormEvents::PRE_SUBMIT) {
         $this->event->setData($data);
     } else {
         throw new \RuntimeException(__CLASS__ . '::' . __FUNCTION__ . ' can only be called in BoltFormsEvents::PRE_SUBMIT');
     }
 }
開發者ID:rudott,項目名稱:bolt-extension-boltforms,代碼行數:8,代碼來源:BoltFormsEvent.php

示例3: preSubmitData

 public function preSubmitData(FormEvent $event)
 {
     $data = $event->getData();
     if (!$data) {
         $data = $event->getForm()->getParent()->getData();
     }
     $form = $event->getForm();
     $targetEntity = null;
     if (isset($data['target_entity'])) {
         $targetEntity = $data['target_entity'];
     }
     $relationType = $this->config->getId()->getFieldType();
     if ($relationType == 'manyToOne') {
         //target_field
         $targetField = null;
         if (isset($data['target_field'])) {
             $targetField = $data['target_field'];
         }
         $form->add($this->formFactory->createNamed('target_field', new TargetFieldType($this->configProvider, $targetEntity), $targetField));
     } else {
         //target_grid
         $targetGrid = null;
         if (isset($data['target_grid'])) {
             $targetGrid = $data['target_grid'];
         }
         $form->add($this->formFactory->createNamed('target_grid', new TargetFieldType($this->configProvider, $targetEntity), $targetGrid, ['multiple' => true, 'label' => 'Related entity data fields']));
         //target_title
         $targetTitle = null;
         if (isset($data['target_title'])) {
             $targetTitle = $data['target_title'];
         }
         $form->add($this->formFactory->createNamed('target_title', new TargetFieldType($this->configProvider, $targetEntity), $targetTitle, ['multiple' => true, 'label' => 'Related entity info title']));
         //target_detailed
         $targetDetailed = null;
         if (isset($data['target_detailed'])) {
             $targetDetailed = $data['target_detailed'];
         }
         $form->add($this->formFactory->createNamed('target_detailed', new TargetFieldType($this->configProvider, $targetEntity), $targetDetailed, ['multiple' => true, 'label' => 'Related entity detailed']));
     }
     if ($event->getName() == FormEvents::PRE_SUBMIT) {
         $event->getForm()->getParent()->setData(array_merge($event->getForm()->getParent()->getData(), $data));
     }
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:43,代碼來源:RelationType.php

示例4: preSubmitData

 public function preSubmitData(FormEvent $event)
 {
     $form = $event->getForm();
     $data = $event->getData();
     if (!$data) {
         $data = $form->getParent()->getData();
     }
     if ($this->config->get('owner') === ExtendScope::OWNER_CUSTOM) {
         $targetEntity = $this->getArrayValue($data, 'target_entity');
         $relationType = $this->config->getId()->getFieldType();
         if ($relationType == 'manyToOne') {
             $this->addTargetField($form, 'target_field', $targetEntity, $this->getArrayValue($data, 'target_field'));
         } else {
             $this->addTargetField($form, 'target_grid', $targetEntity, $this->getArrayValue($data, 'target_grid'), 'Related entity data fields', true);
             $this->addTargetField($form, 'target_title', $targetEntity, $this->getArrayValue($data, 'target_title'), 'Related entity info title', true);
             $this->addTargetField($form, 'target_detailed', $targetEntity, $this->getArrayValue($data, 'target_detailed'), 'Related entity detailed', true);
         }
     }
     if ($event->getName() == FormEvents::PRE_SUBMIT) {
         $form->getParent()->setData(array_merge($form->getParent()->getData(), $data));
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:22,代碼來源:RelationType.php


注:本文中的Symfony\Component\Form\FormEvent::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。