Can i use php @canany inside a table?

Can i use php @canany inside a table?

mathsantosmathsantos Posts: 1Questions: 1Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: I am populating a table with the DataTable, and my last cell in every row is a button or a group of button, depending on the type os the row data. In my button, i would like to add a @canany so I could allow some users to see that buttons or not.
This is my code where i use de data to populate each row:

data.forEach(element => {
element.action = <php @canany(['administrador_responder_almoxarifado']) > <a href="" class="btn btn-success btnanswer" data-toggle="modal" title='Responder pedido' data-target=".response-request" data-viewid="${element.id}"> <i class="fas fa-file-export"></i> </a> <php @endcanany > ;

            var oldDate = new Date(element.date)
            element.date = dateFormat(oldDate)
        });

        $('#tableAlmoxRequests').DataTable({
            destroy        : true,
            paging         : false,
            'lengthChange' : true,
            'searching'    : true,
            'ordering'     : true,
            'info'         : true,
            'autoWidth'    : false,
            'language':{
                'emptyTable': 'Sem dados disponíveis'
             },
            data: data, // Dados de resposta do XHR ( AJAX ) da função no backend;
            columns: [
            {data: "request_number",
                width: "12%"},
            {data: "date"},
            {data: "sector_name"},
            {data: "autor_name",
            width: "15%"},
            {data: "action",
                width: "10%"}
            ]
        });

It is recognizing the php tag, but not the code inside. It seems that the php tag is a tag like a div and the @canany is it's property. Can I make this work some how or it is impossible to make this way?

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.