!20 add createdby field to order form
This commit is contained in:
parent
511f12f10f
commit
70041d7357
4 changed files with 7 additions and 0 deletions
|
@ -26,6 +26,8 @@ final class FoodOrderController extends AbstractController
|
|||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$foodOrder = new FoodOrder;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$foodOrder->setCreatedBy($username);
|
||||
$form = $this->createForm(FoodOrderType::class, $foodOrder, [
|
||||
'action' => $this->generateUrl('app_food_order_new'),
|
||||
]);
|
||||
|
|
|
@ -26,6 +26,9 @@ final class OrderItemController extends AbstractController
|
|||
}
|
||||
|
||||
$orderItem = new OrderItem;
|
||||
$username = $request->cookies->get('username', 'nobody');
|
||||
$orderItem->setCreatedBy($username);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem);
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ final class FoodOrderType extends AbstractType
|
|||
->add(child: 'closedAt', options: [
|
||||
'label' => 'closes at',
|
||||
])
|
||||
->add(child: 'createdBy')
|
||||
;
|
||||
if ($action !== null) {
|
||||
$builder->setAction($action);
|
||||
|
|
|
@ -18,6 +18,7 @@ final class OrderItemType extends AbstractType
|
|||
'data' => $options['name'] ?? '',
|
||||
])
|
||||
->add('extras')
|
||||
->add('createdBy')
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue