Custom Action button at Custom Template

I am trying to use a Custom Action button inside the Custom Template of List page
Custom Template → Table Specific → List Page → CustomTemplateBody

<div class="row">
    			<div class="col col-12">
    				<a href="#" onclick="return ew.submitAction(event, {action: 'star', method: 'ajax', msg: 'Add star?', key: <?PHP $this->keyToJson(true) ?> });">Add Star</a>;
    			</div>
    		</div>

here I got the error as
Call to undefined method Slim\Views\PhpRenderer::keyToJson()here How can I pass the row key value from the Custom Template List Page.

Change this code:

<?PHP $this->keyToJson(true) ?>to: <?php CurrentPage()->keyToJson(true); ?>

mobhar wrote:

Change this code:

<?PHP $this->keyToJson(true) ?>> to: <?php CurrentPage()->keyToJson(true); ?>

Here I got the error as
Uncaught SyntaxError: Unexpected token '}'When I inspect the code from chrome the key value is NULL and it is showing as -
Add Star

This code:

<?php CurrentPage()->keyToJson(true); ?>should be: <?php echo CurrentPage()->keyToJson(true); ?>