Skip to content

Instantly share code, notes, and snippets.

---
src/GroceryCrud/Core/State/StateAbstract.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/GroceryCrud/Core/State/StateAbstract.php b/src/GroceryCrud/Core/State/StateAbstract.php
index 6b37f87..c2c2424 100644
--- a/src/GroceryCrud/Core/State/StateAbstract.php
+++ b/src/GroceryCrud/Core/State/StateAbstract.php
@@ -1311,11 +1311,14 @@ class StateAbstract
public function getFieldTypesAddForm() {
@scoumbourdis
scoumbourdis / customModel.php
Created May 18, 2019 16:18
A quick example of a custom model with a custom query
<?php
use GroceryCrud\Core\Model;
use Zend\Db\Sql\Sql;
class customModel extends Model {
public function customInsert($insertId)
{
$sql = new Sql($this->adapter);
<?php
...
class Examples extends CI_Controller {
...
private function _getDbData() {
$db = [];
include(APPPATH . 'config/database.php');
return [
'adapter' => [
'driver' => 'Pdo_Pgsql',
@scoumbourdis
scoumbourdis / example.php
Last active March 9, 2019 05:12
Grocery CRUD example view page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
@scoumbourdis
scoumbourdis / gce-javascript-options.js
Last active June 16, 2019 16:17
All the JavaScript options for Grocery CRUD Enterprise
$(document).ready(function () {
$('.gc-container').groceryCrud({
openInModal: false, // Prevent forms to open in modal. (Default = true)
hashEvents: false, // Remove the hash events from the URL (Default = true)
callbackBeforeInsert: function (currentForm) {
console.log('callback that is called right before the insert');
},
callbackBeforeUpdate: function (currentForm) {
console.log('callback that is called right before the update');
$(document).ready(function () {
$('.gc-container').groceryCrud({
onRowMount: function (primaryKeyValue) {
$('.grocery-crud-table').on('dblclick', '.gc-datagrid-row[data-id=' + primaryKeyValue + ']', function (event) {
event.preventDefault();
this.onEditClick.apply(this, [primaryKeyValue]);
}.bind(this));
},
onRowUpdate: function (primaryKeyValue) {
$('.grocery-crud-table').on('dblclick', '.gc-datagrid-row[data-id=' + primaryKeyValue + ']', function (event) {
@scoumbourdis
scoumbourdis / CustomersModel.php
Last active May 14, 2026 03:44
A full example of custom model for Grocery CRUD Enterprise
<?php
//CustomersModel.php
use GroceryCrud\Core\Model;
use GroceryCrud\Core\Model\ModelFieldType;
class CustomersModel extends Model {
protected $ci;
protected $db;
-- Please have in mind that as those data are only for testing purposes
-- we did add the full list of cities only for Greece and United Kingdom.
-- Other than that they are few cities for France and Italy in case you would
-- like to test it.
--
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GroceryCrud\Core\GroceryCrud;
class CustomersController extends Controller
{
/**
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GroceryCrud\Core\GroceryCrud;
class CustomersController extends Controller
{
/**