Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use AppBundle\AppBundle;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- use AppBundle\Entity\Plachta;
- class ChangeSheetController extends Controller
- {
- const SHEET_PARAM = 'sheet';
- public function viewAction(Request $request, $idPlachta){
- $em = $this->getDoctrine()->getManager();
- $plachty = $em->getRepository('AppBundle:Plachta')->findAll(array('idPlachta' => $idPlachta));
- $choices = [];
- foreach ($plachty as $plachta) {
- $choices[$plachta->getOpis()] = $plachta->getIdPlachta();
- }
- $form = $this->createFormBuilder()
- ->setAction($this->generateUrl('changesheet_view'))
- ->setMethod('GET')
- ->add('plachta', ChoiceType::class,array('label'=>'Plachta','choices'=>$choices,'attr'=>array('class'=>'form-control', 'style'=>'margin-bottom:15px')))
- ->add('Wybierz', SubmitType::class)
- ->getForm();
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- // formularz wyslany, wsadzamy do sesji
- $request->getSession()->set('plachta', $form['plachta']->getData());
- }
- $request->getSession()->get('plachta');
- return $this->render('inne/profil.html.twig', array(
- 'form' =>$form->createView()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment