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


PHP FormInterface::getData方法代码示例

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


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

示例1: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $data = $form->getData();
     if (empty($data)) {
         $form->setData(array('left' => 0, 'top' => 0, 'width' => $options['width'], 'height' => $options['height'], 'min_width' => $options['width'], 'min_height' => $options['height']));
     }
 }
开发者ID:it-blaster,项目名称:crop-bundle,代码行数:10,代码来源:CropInstanceType.php

示例2: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $center = new GMapsCoordinate($form->getData()->getLatitude(), $form->getData()->getLongitude());
     $this->map->setCenter($center);
     $this->map->setMapOption('zoom', 10);
     $view->vars['map'] = $this->map;
 }
开发者ID:bswiatek,项目名称:sym2rf,代码行数:7,代码来源:CoordinateType.php

示例3: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['object'] = $form->getData();
     if ($options['download_link'] && $view->vars['object']) {
         $view->vars['download_uri'] = $this->storage->resolveUri($form->getData(), 'file');
     }
 }
开发者ID:bface007,项目名称:esgis_gabon,代码行数:7,代码来源:HiddenFileType.php

示例4: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUserRole $model */
             $model = $this->form->getData();
             if (!$model->getUser() || !$model->getRole()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             }
             /** @var User $user */
             $user = $this->em->getRepository('UserBundle:User')->find($model->getUser());
             /** @var Post $role */
             $role = $this->em->getRepository('FaucondorBundle:Post')->find($model->getRole());
             if (!$user) {
                 $this->form->get('user')->addError(new FormError('User with id ' . $model->getUser() . ' not found '));
             }
             if (!$role) {
                 $this->form->get('role')->addError(new FormError('Role with id ' . $model->getRole() . ' not found '));
             }
             $this->onSuccess($user, $role);
             return true;
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:33,代码来源:UserRoleHandler.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: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUser $user */
             $user = $this->form->getData();
             if (!$user->getFirstname() || !$user->getLastname() || !$user->getEmailGalaxy() || !$user->getSection()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             } else {
                 if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL) || !filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                     $error = new FormError('email invalid');
                     if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('email')->addError($error);
                     }
                     if (!filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('emailGalaxy')->addError($error);
                     }
                 } else {
                     $section_id = $this->em->getRepository('FaucondorBundle:Section')->find($user->getSection());
                     $section_code = $this->em->getRepository('FaucondorBundle:Section')->findOneBy(array("code" => $user->getSection()));
                     if (!$section_id && !$section_code) {
                         $this->form->get('section')->addError(new FormError('Section with id ' . $user->getSection() . ' not found'));
                     } else {
                         /** @var Section $section */
                         $section = $section_id ? $section_id : $section_code;
                         $this->onSuccess($user, $section);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:42,代码来源:UserHandler.php

示例7: extractSubmittedData

 /**
  * {@inheritdoc}
  */
 public function extractSubmittedData(FormInterface $form)
 {
     $data = array('submitted_data' => array('norm' => $this->valueExporter->exportValue($form->getNormData())), 'errors' => array());
     if ($form->getViewData() !== $form->getNormData()) {
         $data['submitted_data']['view'] = $this->valueExporter->exportValue($form->getViewData());
     }
     if ($form->getData() !== $form->getNormData()) {
         $data['submitted_data']['model'] = $this->valueExporter->exportValue($form->getData());
     }
     foreach ($form->getErrors() as $error) {
         $errorData = array('message' => $error->getMessage(), 'origin' => is_object($error->getOrigin()) ? spl_object_hash($error->getOrigin()) : null, 'trace' => array());
         $cause = $error->getCause();
         while (null !== $cause) {
             if ($cause instanceof ConstraintViolationInterface) {
                 $errorData['trace'][] = array('class' => $this->valueExporter->exportValue(get_class($cause)), 'root' => $this->valueExporter->exportValue($cause->getRoot()), 'path' => $this->valueExporter->exportValue($cause->getPropertyPath()), 'value' => $this->valueExporter->exportValue($cause->getInvalidValue()));
                 $cause = method_exists($cause, 'getCause') ? $cause->getCause() : null;
                 continue;
             }
             if ($cause instanceof \Exception) {
                 $errorData['trace'][] = array('class' => $this->valueExporter->exportValue(get_class($cause)), 'message' => $this->valueExporter->exportValue($cause->getMessage()));
                 $cause = $cause->getPrevious();
                 continue;
             }
             $errorData['trace'][] = $cause;
             break;
         }
         $data['errors'][] = $errorData;
     }
     $data['synchronized'] = $this->valueExporter->exportValue($form->isSynchronized());
     return $data;
 }
开发者ID:xingshanghe,项目名称:symfony,代码行数:34,代码来源:FormDataExtractor.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->getData() instanceof ProductValueInterface) {
         $this->productFormView->addChildren($form->getData(), $view);
     }
     $view->vars['mode'] = isset($options['block_config']['mode']) ? $options['block_config']['mode'] : 'normal';
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:ProductValueType.php

示例9: getData

 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $data = array('form' => $this->form->createView(), 'element' => $this->element);
     if ($this->form->getData()) {
         $data['id'] = $this->element->getDataIndexer()->getIndex($this->form->getData());
     }
     return $data;
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:11,代码来源:FormElementContext.php

示例10: getResourceNode

 /**
  * Get resource node.
  */
 private function getResourceNode(FormInterface $form)
 {
     if ($form->getData() instanceof ResourceNode) {
         return $form->getData();
     } elseif ($form->getData() && $form->getData() != '') {
         return $this->resourceManager->getById($form->getData());
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:ResourcePickerType.php

示例11: handle

 /**
  * @param FormInterface $form
  * @param Request       $request
  * @param array         $options
  *
  * @return bool
  */
 public function handle(FormInterface $form, Request $request, array $options = null)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $this->handler->updateCredentials($form->getData()->getUser(), $form->getData()->getNewPassword());
     return true;
 }
开发者ID:jpsymfony,项目名称:REST-BEHAT,代码行数:16,代码来源:ChangePasswordFormHandler.php

示例12: testErrorSubmit

 /**
  * @dataProvider getInvalidInputs
  */
 public function testErrorSubmit($submitted, $expected, array $invalidFields = [])
 {
     $this->sut->submit($submitted);
     $this->assertFalse($this->sut->isValid());
     foreach ($invalidFields as $child) {
         $this->assertFalse($this->sut->get($child)->isValid(), "{$child} isValid");
     }
     $this->assertEquals($expected, $this->sut->getData());
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:12,代码来源:PublishingTestCase.php

示例13: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $vars = array('configs' => $options['configs']);
     if ($form->getData()) {
         $fieldConfig = $this->entityManager->getExtendManager()->getConfigProvider()->getConfig($form->getParent()->getData(), $form->getName());
         $fieldName = $fieldConfig->get('target_field');
         $vars['attr'] = array('data-entities' => json_encode(array(array($fieldName => $form->getData()->{'get' . ucfirst($fieldName)}()))));
     }
     $view->vars = array_replace_recursive($view->vars, $vars);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:EntitySelectType.php

示例14: process

 /**
  * @param Quote $quote
  * @return Order|null
  */
 public function process(Quote $quote)
 {
     $this->form->setData($quote);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             return $this->onSuccess($quote, $this->form->getData());
         }
     }
     return null;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:15,代码来源:QuoteToOrderHandler.php

示例15: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $filename = $options['image_filename'] ?: (!is_null($form->getData()) ? $form->getData()->getHGFile()->getFilOriginalFilename() : '');
     $size = $this->fileManager->sizeExistsForType($options['repository_type'], $options['image_preview_size']) ? $options['image_preview_size'] : null;
     $view->vars['image_filename'] = $filename;
     $view->vars['delete_link_class'] = $options['delete_link_class'];
     $view->vars['delete_link_type'] = $options['delete_link_type'];
     $view->vars['delete_link_text'] = $options['delete_link_text'];
     $view->vars['image_preview_class'] = $options['image_preview_class'];
     $view->vars['image_preview_size'] = $size;
     $view->vars['template'] = $options['template'];
 }
开发者ID:hgabka,项目名称:imagerepo-bundle,代码行数:12,代码来源:ImageRepositoryType.php


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