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


PHP Application::form方法代碼示例

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


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

示例1: connect

 public function connect(Application $app)
 {
     $controller = $app['controllers_factory'];
     $controller->get('/', function (Application $app, Request $request) {
         return $app['twig']->render('admin/dashboard.html.twig');
     })->bind('dashboard');
     $controller->match('/settings', function (Application $app, Request $request) {
         $qb = $app['em']->createQueryBuilder();
         $qb->select('s')->from('CMSilex\\Entities\\Setting', 's', 's.att');
         $currentSettings = $qb->getQuery()->getResult();
         $builder = $app->form($currentSettings);
         $form = $builder->add('about', TextareaType::class)->add('github', TextType::class)->add('Save', SubmitType::class)->getForm();
         $form->handleRequest($request);
         if ($form->isSubmitted() && $form->isValid()) {
             $allSettings = $form->getData();
             foreach ($allSettings as $key => $value) {
                 $newSetting = new Setting($key, $value);
                 $app['em']->merge($newSetting);
             }
             $app['em']->flush();
             return $app->redirect($app->url("settings"));
         }
         return $app['twig']->render('admin/settings.html.twig', ['form' => $form->createView()]);
     })->bind('settings')->method('POST|GET');
     return $controller;
 }
開發者ID:cmsilex,項目名稱:cmsilex,代碼行數:26,代碼來源:AdminController.php

示例2: resetPassword

 public function resetPassword(Application $app, Request $request)
 {
     $form = $app->form(new PhraseaRenewPasswordForm());
     if ('POST' === $request->getMethod()) {
         $form->bind($request);
         if ($form->isValid()) {
             $data = $form->getData();
             $user = $app['authentication']->getUser();
             if ($app['auth.password-encoder']->isPasswordValid($user->getPassword(), $data['oldPassword'], $user->getNonce())) {
                 $app['manipulator.user']->setPassword($user, $data['password']);
                 $app->addFlash('success', $app->trans('login::notification: Mise a jour du mot de passe avec succes'));
                 return $app->redirectPath('account');
             } else {
                 $app->addFlash('error', $app->trans('Invalid password provided'));
             }
         }
     }
     return $app['twig']->render('account/change-password.html.twig', array_merge(Login::getDefaultTemplateVariables($app), ['form' => $form->createView()]));
 }
開發者ID:romainneutron,項目名稱:Phraseanet,代碼行數:19,代碼來源:Account.php

示例3: registerAction

 public function registerAction(Application $app, Request $request)
 {
     $builder = $app->form();
     $builder->add('email', EmailType::class)->add('password', RepeatedType::class, ['type' => PasswordType::class, 'first_options' => ['label' => 'Password'], 'second_options' => ['label' => 'Repeat Password']])->add('register', SubmitType::class);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $userInfo = $form->getData();
         $newUser = new User();
         $password = $app->encodePassword($newUser, $userInfo['password']);
         $newUser->setUsername($userInfo['email']);
         $newUser->setPassword($password);
         $newUser->setEnabled(true);
         $newUser->setAccountNonExpired(true);
         $newUser->setAccountNonLocked(true);
         $newUser->setCredentialsNonExpired(true);
         $newUser->setRoles(['ROLE_USER']);
         $app['em']->persist($newUser);
         $app['em']->flush();
         return $app->redirect($app->url('login'));
     }
     return $app->render('authentication/register.html.twig', ['form' => $form->createView()]);
 }
開發者ID:cmsilex,項目名稱:cmsilex,代碼行數:23,代碼來源:AuthenticationController.php

示例4: postSaveTask

 public function postSaveTask(Application $app, Request $request, Task $task)
 {
     if (!$this->doValidateXML($request->request->get('settings'))) {
         return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]);
     }
     $form = $app->form(new TaskForm());
     $form->setData($task);
     $form->bind($request);
     if ($form->isValid()) {
         $app['manipulator.task']->update($task);
         return $app->json(['success' => true]);
     }
     return $app->json(['success' => false, 'message' => implode("\n", $form->getErrors())]);
 }
開發者ID:romainneutron,項目名稱:Phraseanet,代碼行數:14,代碼來源:TaskManager.php

示例5: form

 /**
  * @see \Silex\Application\FormTrait::form
  */
 public function form($data = null, array $options = [], $type = null)
 {
     return $this->app->form($data, $options, $type);
 }
開發者ID:sfblaauw,項目名稱:pulsar,代碼行數:7,代碼來源:AbstractController.php

示例6: postSaveTask

 public function postSaveTask(Application $app, Request $request, Task $task)
 {
     if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) {
         throw new RuntimeException('The use of the task manager is disabled on this instance.');
     }
     if (!$this->doValidateXML($request->request->get('settings'))) {
         return $app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]);
     }
     $form = $app->form(new TaskForm());
     $form->setData($task);
     $form->bind($request);
     if ($form->isValid()) {
         $app['manipulator.task']->update($task);
         return $app->json(['success' => true]);
     }
     return $app->json(['success' => false, 'message' => implode("\n", $form->getErrors())]);
 }
開發者ID:nlegoff,項目名稱:Phraseanet,代碼行數:17,代碼來源:TaskManager.php


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