当前位置: 首页>>代码示例>>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;未经允许,请勿转载。