I’m working on a project and need to get Datatables to help me display a lot of informations for some dashboard. Those informations need to be updatable, as it will be used as an Administration Panel.
My problem is the following :
After following the installation process described in the Documentation, I tried to use the example to check if everything was good. And apparently not, as the following error shows up:
“Cannot autowire argument $dataTableFactory of “AppControllerAdminPanelController::showAction()”: it references class “OminesDataTablesBundleDataTableFactory” but no such service exists.”
I am using PHP 8.* and Symfony 7.* so I should be able to use the example as shown, but I’m wondering if the injection is working correctly since the Symfony 7 update
Here is my Controller :
namespace AppController;
use OminesDataTablesBundleAdapterArrayAdapter;
use OminesDataTablesBundleColumnTextColumn;
use OminesDataTablesBundleDataTableFactory;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentRoutingAnnotationRoute;
class AdminPanelController extends AbstractController
{
#[Route('/admin_panel', name: 'admin_panel')]
public function showAction(Request $request, DataTableFactory $dataTableFactory)
{
$table = $dataTableFactory->create()
->add('firstName', TextColumn::class)
->add('lastName', TextColumn::class)
->createAdapter(ArrayAdapter::class, [
['firstName' => 'Donald', 'lastName' => 'Trump'],
['firstName' => 'Barack', 'lastName' => 'Obama'],
])
->handleRequest($request);
if ($table->isCallback()) {
return $table->getResponse();
}
return $this->render('admin.html.twig',
['datatable' => $table]
);
}
}
I tried modifying the Controller, registering the Bundle in the config/bundles.php file but nothing seemed to be working.
Did some of you ran into the same problem or have an idea to resolve it ?
Thanks a lot for the answers, and please tell me if you need more information, this is my first post ^^’
Taam Ka is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.