Skip to content

Cannot convert value of type string to integer #75

Description

@nikitamaximov

This is a weird one, clearly I'm doing something wrong, just wondering if you can point me to the right direction.
When i let my INT columns be searchable, the search field doesn't accept string values (Err: Cannot convert value of type string to integer), however when I specify my INT columns with 'searchable' => false and I mean all of them, the string columns become searchable, but not the int columns obviously.

My Controller

            $columns = [
            [
                'field' => 'BigDatas.id',   //INT Column
                'data' => 'id',
            ],
            [
                'title' => __('Amount'),   //String Column
                'field' => 'BigDatas.amount',
                'data' => 'amount',
            ],
            [
                'title' => __('Unit'),    //INT Column
                'field' => 'BigDatas.unit',
                'data' => 'unit',
            ],
            [
                'title' => __('Stir'),    //String Column
                'field' => 'BigDatas.stir', 
                'data' => 'stir',
            ]
        ];

        $data = $this->DataTables->find('BigDatas', 'all', [
            'order' => ['id' => 'asc']
        ], $columns);

        $this->set('columns', $columns);
        $this->set('data', $data);
        $this->set('_serialize', array_merge($this->viewVars['_serialize'], ['data']));

My Template

$options = [
    'ajax' => [
        'url' => $this->Url->build() // current controller, action, params
    ],
    'data' => $data,
    'deferLoading' => $data->count(), 
    'columns' => $columns,
    'order' => [0, 'asc'], 
];
echo $this->DataTables->table('bigdatas-table', $options, ['class' => 'table table-striped']);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions