Create edit form for lucense

@param \Slashworks\AppBundle\Model\License $oLicense

@return \Symfony\Component\Form\Form
167175
private function createEditForm(License $oLicense)
        {

            $oForm = $this->createForm(new LicenseType(), $oLicense, array(
                'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())),
                'method' => 'PUT',
            ));

            $oForm->add('submit', 'submit', array('label' => 'Update'));

            return $oForm;
        }
1211765
protected function createCreateForm($entity)
    {
        $form = $this->createForm(
            $this->getAddFormType(), $entity, [
                'action' => $this->generateUrl($this->getRouteName() . "Add", $this->getRouteParams()),
                'method' => 'POST',
            ]
        );

        return $form;
    }
93701
public function getForm() {
		$form = new Form();
		
		$useBlacklist = (count($this->propertyBlacklist) > 0) ? true : false;
		$useWhitelist = (count($this->propertyWhitelist) > 0) ? true : false;
		
		$properties = EntityReader::getProperties($this->entityNamespace);
		foreach ($properties as $property) {
			$name = $property->getName();
			if (($useWhitelist && !in_array($name, $this->propertyWhitelist)) || ($useBlacklist && in_array($name, $this->propertyBlacklist))) {
				continue;
			}
			
			switch ($property->getType()) {
				case Property::PROPERTY_TYPE_COLUMN:
					if (!($property->getAnnotation() instanceof \Doctrine\ORM\Mapping\Id)) {
						$this->addColumnElementToForm($form, $property);
					}
					break;
				case Property::PROPERTY_TYPE_REF_ONE:
					$this->addSingleSelecterElementToForm($form, $property);
					break;
				case Property::PROPERTY_TYPE_REF_MANY:
					$this->addMultiSelecterElementToForm($form, $property);
					break;
				default:
					continue 2;
			}
		}
		
		$submit = new Submit('save');
		$submit->setValue('save');
		$form->add($submit);
		
		return $form;
	}
680679
private function createEditForm(Advert $entity)
    {
        
        $formConfig = array();
        $user = $this->container->get('security.token_storage')->getToken()->getUser();  
        if ($user->isGranted('ROLE_ADMIN') || $user->isGranted('ROLE_SUPER_ADMIN')) {
            $formConfig['admin'] = true;
        }
        $form = $this->createForm('EcommerceBundle\Form\AdvertEditType', $entity, array_merge($formConfig, array(
            'action' => $this->generateUrl('ecommerce_advert_edit', array('id' => $entity->getId())),
            'method' => 'POST',
        )));
        
        return $form;
    }
405149
private function createDeleteForm(Localidad $localidad)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('localidad_delete', array('id' => $localidad->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
1163189
private function createCreateForm(Advert $entity)
    {
        $formConfig = array();
        $user = $this->container->get('security.token_storage')->getToken()->getUser();  
        if ($user->isGranted('ROLE_USER')) {
            $formConfig['actor'] = $user;
        }
        $form = $this->createForm('EcommerceBundle\Form\AdvertType', $entity, array_merge($formConfig, array(
            'action' => $this->generateUrl('ecommerce_advert_new'),
            'method' => 'POST',
        )));

        return $form;
    }
1092492
public function editAction(Request $request, Localidad $localidad)
    {
        $deleteForm = $this->createDeleteForm($localidad);
        $editForm = $this->createForm('Matudelatower\UbicacionBundle\Form\Type\LocalidadType', $localidad);
        $editForm->handleRequest($request);

        if ($editForm->isSubmitted() && $editForm->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($localidad);
            $em->flush();

            return $this->redirectToRoute('localidad_edit', array('id' => $localidad->getId()));
        }

        return $this->render('UbicacionBundle:localidad:edit.html.twig', array(
            'localidad' => $localidad,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        ));
    }
171847
public function updateAction(Request $request)
        {

            /** @var License $oLicense */
            $oLicense = LicenseQuery::create()->findOne();

            if ($oLicense === null) {
                throw $this->createNotFoundException('Unable to find License entity.');
            }

            $editForm = $this->createEditForm($oLicense);
            $editForm->handleRequest($request);

            $aResult = array(
                "success" => false,
                "message" => ""
            );

            $sLico = SystemSettings::get("lico");

            $aHeaders = array(
                'Content-Type: application/json'
            );

            $sDomain = $this->_getSiteURL();

            $aRequest = array(
                'lico' => array(
                    'domain'  => $sDomain,
                    'license' => $oLicense->getSerial()
                ),
            );

            $sRequest = json_encode($aRequest);

            /*
             * Check license against license-server
             */
            $oRequest = curl_init($sLico . "/api/check/license");
            curl_setopt($oRequest, CURLOPT_HTTPHEADER, $aHeaders);
            curl_setopt($oRequest, CURLOPT_TIMEOUT, 120);
            curl_setopt($oRequest, CURLOPT_POST, 1);
            curl_setopt($oRequest, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($oRequest, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest);
            curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true);
            $response    = curl_exec($oRequest);
            $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE);
            $error       = curl_error($oRequest);
            curl_close($oRequest);

            if ($iHttpStatus == 200) {

                $oResponse = json_decode($response);

                if ($editForm->isValid() && $oResponse->valid == true) {
                    $aResult['max_clients'] = $oResponse->max_clients;
                    $aResult['valid_until'] = $oResponse->valid_until;
                    $aResult['domain']      = $sDomain;

                    $aResult['success'] = true;
                    $aResult['message'] = $this->get("translator")->trans("license.update.successful");

                    // license valid, save new license-data
                    $oLicense->setValidUntil($aResult['valid_until']);
                    $oLicense->setMaxClients($aResult['max_clients']);
                    $oLicense->setDomain($sDomain);
                    $oLicense->save();
                } else {
                    $aResult['success'] = false;
                    $aResult['message'] = $this->get("translator")->trans("license.update.failed");
                    $aResult['valid_until'] = strtotime("1970-01-01");
                    $aResult['max_clients'] = 0;
                    $aResult['domain'] = "-";
                }


            } else {

                $aResult['max_clients'] = $oLicense->getMaxClients();
                $aResult['valid_until'] = strtotime($oLicense->getValidUntil());
                $aResult['domain']      = $sDomain;

                $aResult['success'] = false;
                $aResult['message'] = $this->get("translator")->trans("license.update.failed_lico");
            }


            $sResult  = json_encode($aResult);
            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;
        }
433700
public function licenseAgreementAction()
    {
        $this->title("License Agreement");

        // Get license
        $license = file_get_contents(dirname(dirname(__DIR__)) . '/COPYING');
        $this->set("license", $license);

        return $this->render("license_agreement.phtml");
    }
8034
public function editAction()
    {
        /* @var $user \Auth\Entity\User */
        $user = $this->userRepository->find($this->params('id'), \Doctrine\ODM\MongoDB\LockMode::NONE, null, ['allowDeactivated' => true]);
        
        // check if user is not found
        if (!$user) {
            return $this->notFoundAction();
        }
        
        $params = $this->params();
        $forms = $this->formManager;
        /* @var $infoContainer \Auth\Form\UserProfileContainer */
        $infoContainer = $forms->get('Auth/UserProfileContainer');
        $infoContainer->setEntity($user);
        $statusContainer = $forms->get('Auth/UserStatusContainer');
        $statusContainer->setEntity($user);
        
        // set selected user to image strategy
        $imageStrategy = $infoContainer->getForm('info.image')
            ->getHydrator()
            ->getStrategy('image');
		$fileEntity = $imageStrategy->getFileEntity();
		$fileEntity->setUser($user);
		$imageStrategy->setFileEntity($fileEntity);
        
        if ($this->request->isPost()) {
            $formName = $params->fromQuery('form');
            $container = $formName === 'status' ? $statusContainer : $infoContainer;
            $form = $container->getForm($formName);
        
            if ($form) {
                $postData  = $form->getOption('use_post_array') ? $params->fromPost() : [];
                $filesData = $form->getOption('use_files_array') ? $params->fromFiles() : [];
                $form->setData(array_merge($postData, $filesData));
        
                if (!$form->isValid()) {
                    return new JsonModel(
                        array(
                            'valid' => false,
                            'errors' => $form->getMessages(),
                        )
                    );
                }
                
                $this->userRepository->store($user);
        
                if ('file-uri' === $params->fromPost('return')) {
                    $content = $form->getHydrator()->getLastUploadedFile()->getUri();
                } else {
                    if ($form instanceof SummaryFormInterface) {
                        $form->setRenderMode(SummaryFormInterface::RENDER_SUMMARY);
                        $viewHelper = 'summaryForm';
                    } else {
                        $viewHelper = 'form';
                    }
                    $content = $this->viewHelper->get($viewHelper)->__invoke($form);
                }
        
                return new JsonModel(
                    array(
                        'valid' => $form->isValid(),
                        'content' => $content,
                    )
                );
            }
        }
        
        return [
            'infoContainer' => $infoContainer,
            'statusContainer' => $statusContainer
        ];
    }
553375
public function setEditable($callback = NULL, \Nette\Forms\IControl $control = NULL)
    {
        $this->editable = TRUE;
        $this->setClientSideOptions();

        $callback && $this->setEditableCallback($callback);
        $control && $this->setEditableControl($control);

        return $this;
    }
1202384
public function form()
    {
        $this->breadcrumb->onForm();
        $all  = $this->prepare();
        $this->roundRobin->build();
        $form = $this->form->of("antares.tester: test", function (FormGrid $form) use ($all) {
            $model = new Fluent([]);
            $form->setup($this, "antares::tools/tester/prepare", $model, ['id' => 'tester-form']);
            $form->name('Module tester');
            foreach ($all as $module => $tests) {
                $form->fieldset($module, function (Fieldset $fieldset) use ($tests) {
                    $fieldset->control('input:text', '', function($control) use($tests) {
                        $control->field = function() use($tests) {
                            return view('antares/tester::admin.partials._module', ['tests' => $tests]);
                        };
                    });
                });
            }
            $form->layout('antares/tester::admin.partials._form');
        });

        $form->grid->submit = trans('Start testing');
        return $form;
    }
1350083
public function CommentsForm()
    {
        $form = Injector::inst()->create(CommentForm::class, __FUNCTION__, $this);

        // hook to allow further extensions to alter the comments form
        $this->extend('alterCommentForm', $form);

        return $form;
    }
870186
public function createEditForm($id) {
        $entity = $this->read_handler->get($id);
        return $form = $this->doCreate($this->getDefaultTypeClass(), $entity);
    }
751431
private function createEditForm(MessageType $entity)
    {
        $form = $this->createForm(MessageTypeType::class, $entity, array(
            'action' => $this->generateUrl('messagetype_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));
        $this->_addFunctionsToForm($form);

        $form->add('submit', SubmitType::class, array('label' => 'Update'));
        return $form;
    }
913074
public function license()
    {
        $languageId = $this->getLanguageInstance()->getLanguage();
        $utils = $this->getUtilitiesInstance();

        $this->setViewOptions(
            'license.php',
            'STEP_2_TITLE',
            [
                "aLicenseText" => $utils->getLicenseContent($languageId)
            ]
        );
    }
461251
public function editAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('EcommerceBundle:Advert')->find($id);
        $purchase = $em->getRepository('EcommerceBundle:ProductPurchase')->findOneByAdvert($entity);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Advert entity.');
        }

        $form = $this->createEditForm($entity);
        
        return array(
            'entity'      => $entity,
            'purchase'   => $purchase,
            'form' => $form->createView(),
        );
    }