Guest User

Untitled

a guest
Mar 3rd, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Forms;
  5.  
  6. use App\Model\UserAuthenticator;
  7. use Nette;
  8. use Nette\Application\UI\Form;
  9. use Nette\Security\User;
  10. use stdClass;
  11.  
  12. final class SignInFormFactory {
  13.     use Nette\SmartObject;
  14.  
  15.     private FormFactory $factory;
  16.     private User $user;
  17.  
  18.     public function __construct(FormFactory $factory, User $user) {
  19.         $this->factory = $factory;
  20.         $this->user = $user;
  21.     }
  22.  
  23.     public function create(callable $onSuccess): Form {
  24.         $form = $this->factory->create();
  25.  
  26.         $form->addText('name', 'Jméno')->setRequired();
  27.         $form->addPassword('password', 'Heslo')->setRequired();
  28.         $form->addSubmit('send', 'Přihlásit se');
  29.        
  30.         $form->onSuccess[] = function (stdClass $values) use ($onSuccess): void {
  31.             $onSuccess;
  32.         };
  33.  
  34.         return $form;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment