In a search form, the search result cannot be displayed nor are there errors. It automatically returns to the search form and does not go to the Twig page chosen as the destination. Here the code:
<code> #[Route('/admin/actor/', name: 'app_actor_index', methods: ['GET'])]
public function searchactor(Request $request, ActorRepository $actorRepository,): Response
{
$defaultData = [];
$form = $this->createFormBuilder($defaultData)
->add('nombre', TextType::class)
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// $actors = $actorRepository->searchactors($data);
return $this->render('actor/index1.html.twig');
}
return $this->render('actor/buscar.html.twig', array(
'form' => $form->createView() ));
}
</code>
<code> #[Route('/admin/actor/', name: 'app_actor_index', methods: ['GET'])]
public function searchactor(Request $request, ActorRepository $actorRepository,): Response
{
$defaultData = [];
$form = $this->createFormBuilder($defaultData)
->add('nombre', TextType::class)
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// $actors = $actorRepository->searchactors($data);
return $this->render('actor/index1.html.twig');
}
return $this->render('actor/buscar.html.twig', array(
'form' => $form->createView() ));
}
</code>
#[Route('/admin/actor/', name: 'app_actor_index', methods: ['GET'])]
public function searchactor(Request $request, ActorRepository $actorRepository,): Response
{
$defaultData = [];
$form = $this->createFormBuilder($defaultData)
->add('nombre', TextType::class)
->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
// $actors = $actorRepository->searchactors($data);
return $this->render('actor/index1.html.twig');
}
return $this->render('actor/buscar.html.twig', array(
'form' => $form->createView() ));
}
In template index1.html.twig I only put the text as proof: “Hello”. Here the code:
<code>{% extends 'base.html.twig' %}
{% block title %}Actor index{% endblock %}
{% block body %}
Hello
{% endblock %}
</code>
<code>{% extends 'base.html.twig' %}
{% block title %}Actor index{% endblock %}
{% block body %}
Hello
{% endblock %}
</code>
{% extends 'base.html.twig' %}
{% block title %}Actor index{% endblock %}
{% block body %}
Hello
{% endblock %}
But index1.html.twig is never shown. What is wrong in the code?