SuiteCRM parse error when trying to add a js file to a view

536 views Asked by At

I am just trying to add jquery and jquery.maskedinput to a custom edit view for Accounts module. I saw a post explaining this: https://www.suitecrm.co.uk/forum/developer-help/9598-one-of-the-two-required-fields-to-be-filled-in-accounts-module?start=15

My code:

<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Accounts/views/view.edit.php');

class CustomAccountsViewEdit extends AccountsViewEdit {

public function __construct(){
        parent::__construct();
     }


function display(){

 //call parent display method
 #       parent::display();


$js = <<<JS

            <script src="/admin/custom/include/javascript/jquery.min.js" type="text/javascript">
            <script src="/admin/custom/include/javascript/jquery.maskedinput.min.js" type="text/javascript">
    JS;
        parent::display();
        echo $js;

    }

}

The error I am getting:

[error] 1846#0: *244 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected end of file in /usr/share/nginx/html/custom/modules/Accounts/views/view.edit.php on line 31" while reading response header from upstream, client: x.x.x.x, server: , request: "GET /index.php?module=Accounts&action=EditView&return_module=Accounts&return_action=DetailView HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "x.x.x.x", referrer: "http://x.x.x.x/index.php?action=ajaxui"

Any ideas?

1

There are 1 answers

1
Serg Chernata On BEST ANSWER

According to php docs, the heredoc identifier should not be indented. See how there's no space before JS;?

$js = <<<JS

            <script src="/admin/custom/include/javascript/jquery.min.js" type="text/javascript">
            <script src="/admin/custom/include/javascript/jquery.maskedinput.min.js" type="text/javascript">
JS;
        parent::display();
        echo $js;

    }
}