$e["on_insert"] not working in cakephp 3

Questions$e["on_insert"] not working in cakephp 3
Anand asked 1 week ago

Hi Abu,

I have already posted some issues. Again I’m posting same issue here. I have used phpgrid in cakephp3. When i use $e[“on_insert”] = array(“add_record”, null, false);, it will return the some errors. Here I have posted error and code. please rectify this as soon as possible.

Following code will be wrote in controller.

<?php
namespace App\Controller;
use App\Controller\AppController;
use TimeConversion;
require_once(WWW_ROOT . ‘plugins’ . DS . ‘phpgrid’ . DS . ‘lib’ . DS . ‘inc’ . DS . ‘jqgrid_dist.php’);
use jqgrid;
class TransportsController extends AppController{

public function vehicleaddgrid()
{
$this->viewBuilder()->layout(‘gridlayout’);
$this->set(‘title_name’,’Subject’);
$db_conf = array();
$db_conf[“type”] = “Mysqli”; // db2 using odbc
$db_conf[“server”] = “localhost”;//192.168.2.8″; // System DSN
$db_conf[“user”] = “root”;
$db_conf[“password”] = “”;
$db_conf[“database”] = “muthusof_sru”;

$g = new jqgrid($db_conf);
$grid[“caption”] = “Add Main Vehicle”;
$grid[“width”]=1230;
$grid[“height”] = 410;
$grid[“rowList”] = array();
$grid[“rowNum”] = 17;
$grid[“add_options”] = array(‘width’=>’600’);
$grid[“edit_options”] = array(‘width’=>’600′);
$grid[“form”][“position”] = “top”;

$g->set_options($grid);

$g->select_command =’select *
from transportvehiclemaster’;
$g->table = “transportvehiclemaster”;

$col = array();
$col[“title”] = “Id”; // caption of column
$col[“name”] = “id”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = FALSE;
$col[“width”] = “10”;
$col[“hidden”] = false;
$col[“search”] = false;
$cols[] = $col;

$col = array();
$col[“title”] = “Vehicle No”; // caption of column
$col[“name”] = “vehicle_no”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Owner Name”; // caption of column
$col[“name”] = “vehicle_owne_name”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Purchase Date”; // caption of column
$col[“name”] = “purchase_date”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Registeration Date”; // caption of column
$col[“name”] = “registeration_date”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Vehicle Type”; // caption of column
$col[“name”] = “vehicle_type”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Modal”; // caption of column
$col[“name”] = “modal”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = “Make Year”; // caption of column
$col[“name”] = “make_year”; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col[“editable”] = true;
$col[“width”] = “80”;
$col[“hidden”] = false;
$col[“search”] = true;
$cols[] = $col;

$g->set_options($grid);

$g->set_actions(array(
“add”=>true, // allow/disallow add
“edit”=>true, // allow/disallow edit
“delete”=>false, // allow/disallow delete
“view”=>true, // allow/disallow view
“reloadgrid”=>true,
“rowactions”=>true, // show/hide row wise edit/del/save option
“export_excel”=>true, // export excel button
“export_pdf”=>true, // export pdf button
“export_csv”=>false, // export csv button // show/hide export to excel option
“autofilter” => true, // show/hide autofilter for search
“search” => “advance” // show/hide autofilter for search
)
);

//phpgrid_error($cols);exit;

$g->set_columns($cols);

$e[“on_insert”] = array(“add_record”, null, false);
$e[“on_update”] = array(“update_by”, null, false);

$g->set_events($e);
//phpgrid_error(add_record($data));

function add_record($data)
{
phpgrid_error(‘2’.$data);
global $g;
phpgrid_error(‘Sub Category Name Already Processed…’);
}

$out = $g->render(“list”);

$this->set(compact(‘out’));
}
}

Error:

Fatal Error (1): Call to undefined function App\Controller\add_record() in

Thanks

 

Your Answer

14 + 2 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!