W
W
wolverine7772019-04-09 18:04:01
symfony
wolverine777, 2019-04-09 18:04:01

Redirect back to url#anchor - how is it used?

Good afternoon,
Here is my program: 5cacb343c9c56642182435.jpeg There are categories EVALUATIONS (on the left) each of which includes USERS, which must be selected for each EVALUATION from the drop-down list (on the right). After selecting a user and pressing the "add" button, the user is added to the list of the corresponding evaluation. At the same time, the page is updated and an additional user appears in the list of users for each evaluation. You can also use the appropriate button (DELETE) to remove the user from this list.
I would like to understand how to make it so that after entering data in the corresponding field, the page after updating returns to the same place and not to the beginning (so as not to scroll down later and not look for a long time for the name of the category in which the new user appeared).
Here is what my controller looks like:

/**
     * @Route("/attribution", name="attribution")
     */
    public function create () {


        if(
            isset($_POST['evals']) && isset($_POST['user'])) {
            $value = $_POST;                                                                    // data inserted from HTML form (POST)
            
            $EvalUser = new EvaluationUser();

            $EvalUser->setIdEvaluation($value['evals']);
            $EvalUser->setIdUser($value['user']);
            $EvalUser->setEstChargeetudes(true);


            dump($EvalUser); //die;

            $em = $this->getDoctrine()->getManager();

            $em->persist($EvalUser);
            $em->flush();

        }


        $evals = $this
            ->getDoctrine()
            ->getRepository(User::class)
            ->findUserGroups();

        $idevals=array();
        $count=0;


        foreach ($evals as $relation)                           // Creation of array of ID EVALUATION (that does not repeat)
        {
           if (!in_array($relation['id_evaluation'],$idevals))
           {
               $idevals[]=$relation['id_evaluation'];
               $counting['count']=$count;
               $count++;
           }
        }



        $newUserLists=array();

        foreach ($idevals as $id)
        {
            $newUserLists[]=$this->getDoctrine()->getRepository(geodeUtilisateur::class)->findExactGroups($id);
        }


        $users = $this
            ->getDoctrine()
            ->getRepository(geodeUtilisateur::class)
            ->findAll();

        return $this->render('geode/attributionRoles/attrib.html.twig', [
            'onglet' => $onglet, 'evals' => $evals, 'users' => $users, 'newList' => $newUserLists,
            'counts' => $counting
        ]);

    }

I have information that supposedly this can be done somehow using
return redirect()->to(app('url')->previous(). '#hashid'); (from https://laracasts.com/discuss/channels/general-dis... )
Only it is not clear what is at stake. I've been studying PHP+symfony 4 for two weeks - and sometimes it's really hard..
If someone can chew the material a little - I'll be very grateful!
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question