Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace App\Components\Trip;
  5.  
  6. use DateTime;
  7. use Model\Trip\Trip;
  8. use Nette\Application\UI\Form;
  9. use Nette\Utils\ArrayHash;
  10. use Tracy\Debugger;
  11.  
  12. class TripStopsFormFactory {
  13.  
  14.     public function create(Trip $trip) {
  15.         $form = new Form();
  16.         $availableStops = [];
  17.         foreach ($trip->getAvailableStops() as $stop) {
  18.             $availableStops[$stop->getId()] = "";
  19.         }
  20.  
  21.         $form->addText('dateTime', "Date and time of departure");
  22.         $form->addText('numberOfAdults', "Adults (15+)");
  23.         $form->addText('numberOfChildren', "Children (0-14)");
  24.         $form->addText('numberOfLuggage', "Luggage");
  25.         $form->addCheckboxList('selectedStops', "", $availableStops);
  26.  
  27.         $form->addSubmit('submit', "Proceed");
  28.  
  29.         $form->onSuccess[] = function (Form $form, ArrayHash $values) {
  30.             Debugger::barDump($values);
  31.         };
  32.  
  33.         return $form;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement