-1

嘿,我在 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();
    }     
4

1 回答 1

0

这项工作我把字段名弄错了-,-

于 2019-11-12T14:43:06.967 回答