stwe / DatatablesBundle

This Bundle integrates the jQuery DataTables plugin into your Symfony application.
355 stars 236 forks source link

Array to string conversion in search VirtualColumn #970

Closed lemorragia closed 3 years ago

lemorragia commented 3 years ago

I'm experiencing the same problem as #963 , i wrongfully wrote there but it was already a closed issue, so i moved here as a new issue. What i'm doing is uniting two "phone contact" columns (telephone + cellularNumber) searching in both of them at the same time. It didn't work so i simplified it to the minimum: one virtual column as a mirror of another text column (telephone). The configuration:

    public function getLineFormatter()
    {
        return function ($row) {
            $row['phonecontact'] = $row['telephone'];

            return $row;
        };
    }
public function buildDatatable(array $options = []): void
    {
        $this->columnBuilder
            ->add('phonecontact', VirtualColumn::class, [
                'title' => 'Phone',
                'searchable' => true,
                'orderable' => false,
                'search_column' => 'telephone',
                'filter' => [
                    TextFilter::class,
                    ['cancel_button' => false],
                ],
            ])
            ->add('telephone', Column::class, [
                'visible' => false,
            ])
       ;
   }

The problem(if not a configuration problem) seems to be in the query generation: inside doctrine\orm[..]\Comparison.php the left operand is indeed an array: [0=>'partner.telephone'], and the code fails on an Array-to-String conversion. Any ideas?

nexxome commented 3 years ago

I've created a pull request to resolve it.