createView() public method

Creates a view.
public createView ( Symfony\Component\Form\FormView $parent = null ) : Symfony\Component\Form\FormView
$parent Symfony\Component\Form\FormView The parent view
return Symfony\Component\Form\FormView The view
 /**
  * @param $page
  * @param null $template
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @throws \Exception
  */
 public function renderList($page, $template = null)
 {
     $user = $this->getUser();
     $tpl = null === $template ? $this->templatePath . 'list.html.twig' : $template;
     if ($this->filterForm) {
         $this->filterForm = $this->createForm($this->filterForm);
     }
     $qb = $this->buildFilterQuery();
     $paginator = $this->get('knp_paginator');
     $pagination = $paginator->paginate($qb->getQuery(), $page, $this->list_item_per_page, $this->defaultSortList);
     return $this->render($tpl, array('user' => $user, 'nbPerPage' => $this->list_item_per_page, 'page' => $page, 'form' => $this->filterForm ? $this->filterForm->createView() : null, 'baseRoute' => $this->baseRoute, 'entityName' => $this->entityName, 'list' => ['records' => $pagination, 'fields' => $this->listColumn, 'parameters' => $this->listConf, 'actions' => $this->listActions], 'actionsList' => $this->actionsList(), 'listTitle' => $this->listTitle));
 }
 /**
  * Edit a group type
  *
  * @param GroupType $groupType
  *
  * @Template
  * @AclAncestor("pim_enrich_group_type_edit")
  * @return array
  */
 public function editAction(GroupType $groupType)
 {
     if ($this->groupTypeHandler->process($groupType)) {
         $this->addFlash('success', 'flash.group type.updated');
     }
     return array('form' => $this->groupTypeForm->createView());
 }
 /**
  * getViewFiltersForm
  * 
  * @return \Symfony\Component\Form\Form::createView or false
  */
 protected function getViewFiltersForm()
 {
     if ($this->filter_fields) {
         return $this->filter_form->createView();
     }
     return false;
 }
 /**
  * @return FormView
  */
 public function getFormView()
 {
     if (is_null($this->formView)) {
         $this->formView = $this->form->createView();
     }
     return $this->formView;
 }
 /**
  * Edit a family
  *
  * TODO : find a way to use param converter with interfaces
  *
  * @param Family $family
  *
  * @Template
  * @AclAncestor("pim_enrich_family_index")
  *
  * @return array
  */
 public function editAction(Family $family)
 {
     if ($this->familyHandler->process($family)) {
         $this->addFlash('success', 'flash.family.updated');
     }
     return ['form' => $this->familyForm->createView(), 'attributesForm' => $this->getAvailableAttributesForm($family->getAttributes()->toArray())->createView(), 'channels' => $this->channelManager->getChannels()];
 }
 /**
  * Edit a group
  *
  * TODO : find a way to use param converter with interfaces
  *
  * @param Group $group
  *
  * @Template
  * @AclAncestor("pim_enrich_group_edit")
  *
  * @return array
  */
 public function editAction(Group $group)
 {
     if ($this->groupHandler->process($group)) {
         $this->addFlash('success', 'flash.group.updated');
     }
     return ['form' => $this->groupForm->createView(), 'currentGroup' => $group->getId()];
 }
 /**
  * Edit a group type
  *
  * @param GroupType $groupType
  *
  * @Template
  * @AclAncestor("pim_enrich_grouptype_edit")
  *
  * @return array
  */
 public function editAction(GroupType $groupType)
 {
     if ($this->groupTypeHandler->process($groupType)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.group type.updated'));
     }
     return ['form' => $this->groupTypeForm->createView()];
 }
Example #8
0
 protected function assertViewIsValid(Form $form, array $formData)
 {
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
 /**
  * Edit attribute form
  *
  * @param int $id
  *
  * @Template("PimEnrichBundle:Attribute:form.html.twig")
  * @AclAncestor("pim_enrich_attribute_edit")
  *
  * @return array
  */
 public function editAction(Request $request, $id)
 {
     $attribute = $this->findAttributeOr404($id);
     if ($this->attributeHandler->process($attribute)) {
         $request->getSession()->getFlashBag()->add('success', new Message('flash.attribute.updated'));
     }
     return ['form' => $this->attributeForm->createView(), 'locales' => $this->localeRepository->getActivatedLocaleCodes(), 'disabledLocales' => $this->localeRepository->findBy(['activated' => false]), 'measures' => $this->measuresConfig, 'created' => $this->versionManager->getOldestLogEntry($attribute), 'updated' => $this->versionManager->getNewestLogEntry($attribute)];
 }
 /**
  * Edit channel
  *
  * @param Channel $channel
  *
  * @Template
  * @AclAncestor("pim_enrich_channel_edit")
  * @return array
  */
 public function editAction(Channel $channel)
 {
     if ($this->channelHandler->process($channel)) {
         $this->addFlash('success', 'flash.channel.saved');
         return $this->redirect($this->generateUrl('pim_enrich_channel_edit', array('id' => $channel->getId())));
     }
     return array('form' => $this->channelForm->createView());
 }
 /**
  * Edit channel
  *
  * @param Channel $channel
  *
  * @Template
  * @AclAncestor("pim_enrich_channel_edit")
  *
  * @return array
  */
 public function editAction(Channel $channel)
 {
     if ($this->channelHandler->process($channel)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.channel.saved'));
         return new RedirectResponse($this->router->generate('pim_enrich_channel_edit', ['id' => $channel->getId()]));
     }
     return ['form' => $this->channelForm->createView()];
 }
 /**
  * Edit attribute form
  *
  * @param Request $request
  * @param integer $id
  *
  * @Template("PimEnrichBundle:Attribute:form.html.twig")
  * @AclAncestor("pim_enrich_attribute_edit")
  * @return array
  */
 public function editAction(Request $request, $id)
 {
     $attribute = $this->findAttributeOr404($id);
     if ($this->attributeHandler->process($attribute)) {
         $this->addFlash('success', 'flash.attribute.updated');
         return $this->redirectToRoute('pim_enrich_attribute_edit', array('id' => $attribute->getId()));
     }
     return array('form' => $this->attributeForm->createView(), 'locales' => $this->localeManager->getActiveLocales(), 'disabledLocales' => $this->localeManager->getDisabledLocales(), 'measures' => $this->measuresConfig, 'created' => $this->versionManager->getOldestLogEntry($attribute), 'updated' => $this->versionManager->getNewestLogEntry($attribute));
 }
 /**
  * Edit attribute group
  *
  * @param AttributeGroup $group
  *
  * @Template
  * @AclAncestor("pim_enrich_attributegroup_edit")
  *
  * @return array
  */
 public function editAction(AttributeGroup $group)
 {
     $groups = $this->attributeGroupRepo->getIdToLabelOrderedBySortOrder();
     if ($this->formHandler->process($group)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.attribute group.updated'));
         return new RedirectResponse($this->router->generate('pim_enrich_attributegroup_edit', ['id' => $group->getId()]));
     }
     return ['groups' => $groups, 'group' => $group, 'form' => $this->form->createView(), 'attributesForm' => $this->getAvailableAttributesForm($this->getGroupedAttributes())->createView()];
 }
 /**
  * Edit attribute group
  *
  * @param AttributeGroup $group
  *
  * @Template
  * @AclAncestor("pim_enrich_attributegroup_edit")
  *
  * @return array
  */
 public function editAction(AttributeGroup $group)
 {
     $groups = $this->attributeGroupRepo->getIdToLabelOrderedBySortOrder();
     if ($this->formHandler->process($group)) {
         $this->addFlash('success', 'flash.attribute group.updated');
         return $this->redirectToRoute('pim_enrich_attributegroup_edit', ['id' => $group->getId()]);
     }
     return ['groups' => $groups, 'group' => $group, 'form' => $this->form->createView(), 'attributesForm' => $this->getAvailableAttributesForm($this->getGroupedAttributes())->createView()];
 }
 public function transform(Form $form)
 {
     $formView = $form->createView();
     $question = new AlwaysReturnKeyOfChoiceQuestion($this->questionFrom($form), $formView->vars['choices'], $this->defaultValueFrom($form));
     if ($form->getConfig()->getOption('multiple')) {
         $question->setMultiselect(true);
     }
     return $question;
 }
Example #16
0
 protected function createFormView()
 {
     if (null === $this->form) {
         throw new \LogicException('Can\'t create form view');
     }
     if (null === $this->formView) {
         $this->formView = $this->form->createView();
     }
     return $this->formView;
 }
 /**
  * Edit an association type
  *
  * @param Request $request
  * @param int     $id
  *
  * @Template
  * @AclAncestor("pim_enrich_associationtype_edit")
  *
  * @return array
  */
 public function editAction(Request $request, $id)
 {
     $associationType = $this->findOr404('PimCatalogBundle:AssociationType', $id);
     if ($this->assocTypeHandler->process($associationType)) {
         $this->addFlash('success', 'flash.association type.updated');
         return $this->redirectToRoute('pim_enrich_associationtype_edit', ['id' => $id]);
     }
     $usageCount = $this->assocRepository->countForAssociationType($associationType);
     return ['form' => $this->assocTypeForm->createView(), 'usageCount' => $usageCount];
 }
Example #18
0
File: Image.php Project: fire1/liby
 /**
  * TODO Създаване на изходна информация
  * @param $template
  * @param array $tags
  * @return JsonResponse
  */
 public function response($template, array $tags = array())
 {
     $formView = $this->form->createView();
     $formView->vars['form']->children['FileUpload']->vars['full_name'] .= '[]';
     $tags['form'] = $formView;
     if ($this->ajax) {
         return $this->jsonResponse();
     }
     return $this->ap['twig']->render($template, $tags);
 }
 /**
  * {@inheritdoc}
  */
 protected function getAttributes($attributes, StructureInterface $structure = null, $preview = false)
 {
     if ($this->attributes === null) {
         // for performance only called once
         $this->attributes = parent::getAttributes($attributes, $structure, $preview);
     }
     if (!empty($this->form)) {
         $this->attributes['form'] = $this->form->createView();
     }
     return $this->attributes;
 }
 /**
  * Edit a family
  *
  * @param int $id
  *
  * @Template
  * @AclAncestor("pim_enrich_family_index")
  *
  * @return array
  */
 public function editAction($id)
 {
     $family = $this->familyRepository->find($id);
     if (null === $family) {
         throw new NotFoundHttpException(sprintf('%s entity not found', $this->familyClass));
     }
     if ($this->familyHandler->process($family)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.family.updated'));
     }
     return ['form' => $this->familyForm->createView(), 'attributesForm' => $this->getAvailableAttributesForm($family->getAttributes()->toArray())->createView(), 'channels' => $this->channelManager->getChannels()];
 }
 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \FSi\Bundle\AdminBundle\Admin\CRUD\FormElement $element
  * @param \FSi\Component\DataIndexer\DataIndexerInterface $dataIndexer
  * @param \Symfony\Component\HttpFoundation\Request $request
  */
 function it_have_array_data($form, $element, $dataIndexer, $request)
 {
     $form->createView()->willReturn('form_view');
     $form->getData()->willReturn(null);
     $this->handleRequest($request)->shouldReturn(null);
     $this->getData()->shouldBeArray();
     $this->getData()->shouldHaveKeyInArray('form');
     $this->getData()->shouldHaveKeyInArray('element');
     $form->getData()->willReturn(array('object'));
     $element->getDataIndexer()->willReturn($dataIndexer);
     $dataIndexer->getIndex(array('object'))->willReturn('id');
     $this->getData()->shouldHaveKeyInArray('id');
 }
 /**
  * Edit an association type
  *
  * @param int     $id
  *
  * @Template
  * @AclAncestor("pim_enrich_associationtype_edit")
  *
  * @return array
  */
 public function editAction($id)
 {
     $associationType = $this->assocTypeRepo->find($id);
     if (!$associationType) {
         throw new NotFoundHttpException(sprintf('%s entity not found', 'PimCatalogBundle:AssociationType'));
     }
     if ($this->assocTypeHandler->process($associationType)) {
         $this->request->getSession()->getFlashBag()->add('success', new Message('flash.association type.updated'));
         return new RedirectResponse($this->router->generate('pim_enrich_associationtype_edit', ['id' => $id]));
     }
     $usageCount = $this->assocRepository->countForAssociationType($associationType);
     return ['form' => $this->assocTypeForm->createView(), 'usageCount' => $usageCount];
 }
 protected function initForm()
 {
     $filters = array();
     if ($this->request->cookies->get('filters')) {
         $filters = unserialize($this->request->cookies->get('filters'));
     }
     $date = null;
     if (isset($filters['date'])) {
         $date = $filters['date'];
     }
     $this->form = $this->createFormBuilder();
     $this->form->setAction($this->generateUrl('datapresentation_filter_set'))->add('siteId', 'text', array('required' => false, 'attr' => array('value' => isset($filters['siteId']) ? $filters['siteId'] : '')))->add('userId', 'text', array('required' => false, 'attr' => array('value' => isset($filters['userId']) ? $filters['userId'] : '')))->add('customerId', 'text', array('required' => false, 'attr' => array('value' => isset($filters['customerId']) ? $filters['customerId'] : '')))->add('productId', 'text', array('required' => false, 'attr' => array('value' => isset($filters['productId']) ? $filters['productId'] : '')))->add('host', 'text', array('required' => false, 'attr' => array('value' => isset($filters['host']) ? $filters['host'] : '')))->add('page', 'text', array('required' => false, 'attr' => array('value' => isset($filters['page']) ? $filters['page'] : '')))->add('pageType', 'text', array('required' => false, 'attr' => array('value' => isset($filters['pageType']) ? $filters['pageType'] : '')))->add('event', 'text', array('required' => false, 'attr' => array('value' => isset($filters['event']) ? $filters['event'] : '')))->add('date', 'date', array('required' => false, 'input' => 'datetime', 'widget' => 'text', 'data' => $date, 'attr' => array('class' => 'date-input')))->add('today', 'checkbox', array('required' => false, 'attr' => array('class' => 'checkbox-input')));
     $this->form->add('save', 'submit', array('label' => ' ', 'attr' => array('class' => 'green-button fa fa-list fa-lg', 'title' => 'filter')));
     $this->form = $this->form->getForm()->handleRequest($this->request);
     $this->formView = $this->form->createView();
 }
Example #24
0
 protected function processForm($type, Form $form)
 {
     $repo = $this->get('social.publishing.repository');
     $form->handleRequest($this->getRequest());
     // remove the current edited entity from the listing
     if (!is_null($form->getData())) {
         $param['skipped_pub'] = $form->getData()->getId();
     }
     if ($form->isValid()) {
         $newPost = $form->getData();
         try {
             $repo->persist($newPost);
             $this->pushFlash('notice', 'Message saved');
             return $this->redirectRouteOk('wall_index', ['wallNick' => $this->getUser()->getUsername(), 'wallFilter' => 'self'], 'anchor-' . $newPost->getId());
         } catch (\MongoException $e) {
             $this->pushFlash('warning', 'Cannot save message');
         }
     }
     $param['form'] = $form->createView();
     $template = "TrismegisteSocialBundle:Content:form/{$type}.html.twig";
     return $this->renderWall($this->getUser()->getUsername(), 'self', $template, $param);
 }
Example #25
0
 /**
  * Returns a string representation of all form errors (including children errors).
  *
  * This method should only be used in ajax calls.
  *
  * @param Form $form         The form to parse
  * @param bool $withChildren Do we parse the embedded forms
  *
  * @return string A string representation of all errors
  */
 public function getRecursiveReadableErrors($form, $withChildren = true, $translationDomain = null, $level = 0)
 {
     $errors = '';
     $translationDomain = $translationDomain ? $translationDomain : $form->getConfig()->getOption('translation_domain');
     //the errors of the fields
     foreach ($form->getErrors() as $error) {
         //the view contains the label identifier
         $view = $form->createView();
         $labelId = $view->vars['label'];
         //get the translated label
         if ($labelId !== null) {
             $label = $this->translator->trans($labelId, [], $translationDomain) . ' : ';
         } else {
             $label = '';
         }
         //in case of dev mode, we display the item that is a problem
         //getCause cames in Symfony 2.5 version, this is just a fallback to avoid BC with previous versions
         if ($this->debug && method_exists($error, 'getCause')) {
             $cause = $error->getCause();
             if ($cause !== null) {
                 $causePropertyPath = $cause->getPropertyPath();
                 $errors .= ' ' . $causePropertyPath;
             }
         }
         //add the error
         $errors .= $label . $this->translator->trans($error->getMessage(), [], $translationDomain) . "\n";
     }
     //do we parse the children
     if ($withChildren) {
         //we parse the children
         foreach ($form->getIterator() as $child) {
             $level++;
             if ($err = $this->getRecursiveReadableErrors($child, $withChildren, $translationDomain, $level)) {
                 $errors .= $err;
             }
         }
     }
     return $errors;
 }
Example #26
0
 public function createView()
 {
     $this->view = $this->form->createView();
     return $this;
 }
Example #27
0
 /**
  * Store corporate
  *
  * @param Form $storeCorporateType Store corporate type
  *
  * @return array Result
  *
  * @Route(
  *      path = "profile",
  *      name = "admin_store_corporate",
  *      methods = {"GET", "POST"}
  * )
  * @Template
  *
  * @EntityAnnotation(
  *      class = {
  *          "factory" = "elcodi.wrapper.store",
  *          "method" = "get",
  *          "static" = false
  *      },
  *      name = "store",
  *      persist = false
  * )
  * @FormAnnotation(
  *      class         = "elcodi_admin_store_form_type_store_corporate",
  *      name          = "storeCorporateType",
  *      entity        = "store",
  *      handleRequest = true
  * )
  */
 public function corporateAction(Form $storeCorporateType)
 {
     if ($storeCorporateType->isValid()) {
         $this->saveStoreAndAddFlash($storeCorporateType->getData());
         return $this->redirectRoute("admin_store_corporate");
     }
     return ['form' => $storeCorporateType->createView()];
 }
 /**
  * Process the subscribre form
  *
  * @param Form $form
  * @return string HTML
  */
 protected function processForm(Form $form)
 {
     $results = array();
     $showForm = true;
     if ('POST' == $this->app['request']->getMethod()) {
         $form->bind($this->app['request']);
         if ($form->isValid()) {
             $data = $form->getData();
             $results = $this->addSubscriber($data);
             $showForm = isset($results['error']);
         } else {
             $results['error'] = $this->config['messages']['error'];
         }
     }
     $formhtml = $this->app['twig']->render($this->config['template'], array("form" => $form->createView(), "message" => isset($results['message']) ? $results['message'] : '', "error" => isset($results['error']) ? $results['error'] : '', "showform" => $showForm, "button_text" => $this->config['button_text'], "secret" => isset($this->config['admin_secret']) ? $this->config['admin_secret'] : '', "secret_default" => $this->app['nls.defaults']['admin_secret']));
     return $formhtml;
 }
Example #29
0
 /**
  * render Widget form.
  *
  * @param Form   $form
  * @param Widget $widget
  * @param object $entity
  *
  * @return form
  */
 public function renderForm(Form $form, Widget $widget, $entity = null)
 {
     //the template displayed is in the widget bundle
     $templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName('edit', $widget);
     return $this->container->get('templating')->render($templateName, ['widget' => $widget, 'slot' => $widget->getWidgetMap()->getSlot(), 'view' => $this->container->get('victoire_core.current_view')->getCurrentView(), 'form' => $form->createView(), 'id' => $widget->getId(), 'entity' => $entity]);
 }
Example #30
0
 /**
  * Sets a specific theme for the form
  *
  * @param Form   $form
  * @param string $template
  * @param mixed  $theme
  *
  * @return \Symfony\Component\Form\FormView
  */
 protected function setFormTheme(Form $form, $template, $theme = null)
 {
     $formView = $form->createView();
     if (empty($theme)) {
         return $formView;
     }
     $templating = $this->factory->getTemplating();
     if ($templating instanceof DelegatingEngine) {
         $templating->getEngine($template)->get('form')->setTheme($formView, $theme);
     } else {
         $templating->get('form')->setTheme($formView, $theme);
     }
     return $formView;
 }