Answer the question
In order to leave comments, you need to log in
Redirect back to url#anchor - how is it used?
Good afternoon,
Here is my program: 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
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question