Skip to content
Advertisement

I duplicated code and got different output

Got a weird one here. I’m just going to give snippets, they talk for themselves. I just want to know what is going on.

Controller:

JavaScript

Then the view has this for data handling, and puts it in a table:

JavaScript

Wanna see the result?Table of the output

As can be seen, there are 2 of the same columns (testing this thing out) and the first takes text literal, the second constructs the elements into a working delete button (well a button to show the modal asking if you’re sure you want to delete). We’re talking about the addColumn(link) and addColumn(action) sections in the controller. I have no idea why they would produce different results except if ‘action’ is a reserved name for a table column that leads to a different interpretation of the string (not sanitizing the string vs sanitizing).

Advertisement

Answer

By default, Yajra Datatables set ‘action’ column as raw, you can see it in the config file: vendor/yajra/laravel-datatables-oracle/src/config/datatables.php (if you didn’t publish this vendor file) under columns.raw

enter image description here

Edit: if you want to make the ‘link’ column as raw, you can chain the rawColumns function in your controller. Read more

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement