Hello, I have using Codeigniter (CI) with DHTMLX
Because I don’t know how to “attachEvent” to FormConnector with Codeigniter, so I am trying by myself
When I am inserting correct data, AfterInsert Event returning value is OK (nama_dokter).
When I am trying insert duplicate data on unique field, error message shown CodeIgniter error, not call onDBError function
Please help me if anything error with my code :
[code]<?php
defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);
use Dhtmlx\Connector\GridConnector;
use Dhtmlx\Connector\FormConnector;
use Dhtmlx\Connector\ComboConnector;
class Dokter extends CI_Controller {
public function grid() {
$dokterGrid = new GridConnector($this->db, "PHPCI");
$sql = "SELECT * FROM dokter";
$dokterGrid->dynamic_loading('20');
$dokterGrid->render_sql($sql, 'kode_dokter', 'nama_dokter,spesialis,alamat_dokter,no_tlp');
}
public function form() {
$formdata = new FormConnector($this->db, "PHPCI");
$formdata->event->attach(new dokterEvent());
$formdata->render_table('dokter', 'kode_dokter', 'nama_dokter,spesialis,alamat_dokter,no_tlp');
}
}
class dokterEvent {
public function afterUpdate($action) {
$nama_dokter = $action->get_value(‘nama_dokter’);
$action->set_response_text($nama_dokter);
}
public function afterInsert($action) {
$nama_dokter = $action->get_value(‘nama_dokter’);
$action->set_response_text($nama_dokter);
}
public function onDBError($action, $exception){
$msg = $exception->getMessage();
$action->set_response_text($msg);
}
}
?>[/code]
Thanks