嘿,我在 Symfony 4.3 中使用 ominis/datatables 包。我从 Intl 存储在我的数据库国家代码中。Intl::getRegionBundle()->getCountryName($value)
当我使用表格构建器时如何使用。我的代码如下(但不工作)
$table = $this->datatableFactory->create([])
->add('name', TextColumn::class, ['label' => 'Name', 'className' => 'bold'])
->add('adress', TextColumn::class, ['label' => 'Adress', 'className' => 'bold'])
->add('city', TextColumn::class, ['label' => 'City', 'className' => 'bold'])
->add('state', TextColumn::class, ['label' => 'State', 'className' => 'bold'])
->add('country_code', TextColumn::class, ['label' => 'Country', 'className' => 'bold', 'render' => function($value, $context) {
return Intl::getRegionBundle()->getCountryName($value);}])
->add('vat', TextColumn::class, ['label' => 'VAT', 'className' => 'bold'])
->add('regon', TextColumn::class, ['label' => 'Regon', 'className' => 'bold'])
->createAdapter(ORMAdapter::class, [
'entity' => Company::class
])
->handleRequest($request);
if ($table->isCallback()) {
return $table->getResponse();
}