A CRUD in five minutes with BF
Paul Hodel

If you are new to Bossanova Framework, this article is going to be very useful from a practical point of view to present you the fundamentals of the platform. So, the following instructions is to give developers the basic instructions on how to create the simplest CRUD module considering common best practices.

If don't have BF installed yet we recommend to read our article From zero to Bossanova Framework with Bitnami. So without further due, the idea is create a countries CRUD, so please follow the instructions.


Please create the table:

CREATE TABLE countries
  country_id serial NOT NULL,
  country_name character varying(255) NOT NULL,
  country_status smallint,
  CONSTRAINT countries_pkey PRIMARY KEY (country_id)


Please create a new model file to: /models/Countries.class.php


namespace models;

use bossanova\Model\Model;

class Countries extends Model
    // This is just a demo for the grid
    public function grid ()
        // Get all countries
        $result = $this->database->table("countries")
            ->column("country_id, country_name, country_status")
            ->argument(1, "country_status", 1)

        // Format grid and return the data
        return $this->gridFormat($result);


Please create the following folder structure:



Please create a new PHP class: /modules/Countries/Countries.class.php


namespace modules\Countries;

use bossanova\Module\Module;

class Countries Extends Module
    public function __default ()
    public function grid ()
        // Load model
        $countries = new \models\Countries;

        // Load the data
        $grid = $countries->grid();

        // return the array in a json format
        return $this->json_encode($grid);


Create a new plain HTML view file: /modules/Countries/views/countries.html

<form id='countries_form'>
<table cellspacing='10' class='adminForm'>

    <table cellpadding="4" cellspacing="0">
    <tr><td><label>Country ID</label><br><input type="text" name="country_id" style="width:280px;" readonly="readonly"></td></tr>
    <tr><td><label>Country Name</label><br><input type="text" name="country_name" style="width:280px;"></td></tr>
    <tr><td><label>Country Status</label><br>
        <select type="text" name="country_status" style="width:280px;">
        <option value="1">Enabled</option>
        <option value="0">Disable</option></select></td></tr>

    <input type="button" value="Save" name="save" style="width:90px;">
    <input type="reset" value="New" style="width:90px;">

<div style="padding:10px;">
    <div class="grid" id="countries_form_grid"></div>

$(document).ready(function() {
    $('#countries_form').form({ url: bossanova_url + 'countries', primarykey:'country_id' });

        url: bossanova_url + 'countries/grid',
            {title:'Id',width:'40', search:'1'},
            {title:'Name',width:'120', search:'1'},
            {title:'Status',width:'100', search:'2', search_combo:{'1':'Enabled','0':'Disabled'}},

function countries_open (id)
    $('#countries_form').form('open', id);

function countries_delete (id)
    if (confirm('Are you sure?')) {
        $('#countries_form').form('delete', id, function () {


Now to test your new module, you can call the URL below:

To see it live:

Behind the scenes

Basically, all RESTful requests from the frontend are implemented by the Bossanova UI FORM Plugin [public/componentes/bossanova/js/jquery.form.js]. So the following actions will be performed via ajax.


Those methods are natively implemented by the Module Library and inhetered by your Countries class to automatically handle the requests. Of course, these methods can be overwrite to fits specific needs. If you would like more information about how BF handles restful requests please check the documentation of Fundalmentals of Bossanova.