Hi,
I need to create a module that create a new tab in the back office in which it display a form that allow you to create a list of product and prices.
I managed to create the tab and link a controller to it called AdminProductListing.
In this controller I want to create 2 methods.
displayForm() that would simply render a twig template containing a form.
formSubmitHandler() when submitting the form it will redirect to this method that will handle the whole logic.
Here is my current code :
@Modules/MyModule/views/templates/admin/form.html.twig
{% extends '@PrestaShop/Admin/layout.html.twig' %} {% block content %} <h1 class="text-center">Create a new product list</h1> <form action="{{ path("form_listing_price" }}" method="get" class="text-center d-flex w-100"> </form> {% endblock %}
@Modules/MyModule/controllers/admin/AdminProductListingController.php
class AdminProductListingController extends FrameworkBundleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->display = 'test';
}
public function displayForm(): ?Response
{
return $this->render('@Modules/specificproductlisting/views/templates/admin/form.html.twig');
}
/**
* @\Symfony\Component\Routing\Annotation\Route(name="form_listing_price", path="/form_listing_price")
*/
public function formHandler()
{
}
}
At moment it throw this error :
Attempted to call an undefined method named "run" of class "AdminProductListingController".
I know how this works in Symfony but it doesn't seems to be the same exact logic.