Update/Insert Form issue with CRUD


I’ve been testing ATK4 today and I really enjoy its logic, great work on it and thanks for keeping it open-source!

Now I do have an issue I haven’t been able to resolve: basically I tried to create a CRUD to edit some database table close to the quickstart example. The list of items is being correctly displayed but I can’t seem to be able to insert/update/delete items.

I opened the console on Firefox (F12) and there is the following error whenever a pop-up (for insert/update) opens:

TypeError: can't assign to property "id" on "": not an object          atkjs-ui.min.js:1:41903

This results into the pop-up displaying infinitely a loading animation but nothing more.

When deleting an item, I simply have a blank line pop-up. Any idea about what could cause this?

Here are snippets of the code:



$app = new CustomApp('Secure_DL');

//custom object that deals with retrieving connection info from .conf files
$db = ConnectionFactory::getFactory()->getDatabase();


$crud = $app->add([
    'fieldsCreate' => ['paths','expiration_date'],
    'fieldsUpdate' => ['expiration_date', 'valid']
$crud->setModel(new Link($app->db));


class Link extends \atk4\data\Model{
public $table = 'Links';

function init()
    $this->addField('hash', [
        'type' => 'hash',
        'caption' => 'Hash'
    $this->getElement('hash')->read_only = true;
    $this->addField('expiration_date', [
        'type' => 'date',
        'caption' => 'Expiration Date'
    $this->addField('paths', ['caption' => 'Paths']);
    $this->addField('valid', [
        'type' => 'boolean',
        'caption' => 'Valid']);


class CustomApp extends atk4\ui\App{
public function __construct($defaults = [])
    $this->ui_persistence = new CustomPersistence();



class CustomPersistence extends\atk4\ui\Persistence\UI {
public function _typecastSaveField(\atk4\data\Field $f, $value)
    switch ($f->type) {
        case 'hash':
            //converts bin value to some string representation using custom alphabet
            return MD5_RawTo24($value);
    return parent::_typecastSaveField($f, $value);

Any help would be most welcome :slight_smile:


Can you tell if the error is caused by your implementation of hash field or it’s due to some bug in JS?


I have created a new table in my db, so that the ‘hash’ field is basically just text and there is no need for the CustomePersistence. I still encounter the same issue, with the same error in the JS console so I’d say it’s a JS issue… Is there any way to get more info for you?


I was able to fix my issue actually! I must have not understood something, I tried a custom implementation of a router using:

$path_str = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

And had an if-else block on the path to print various info (using echo) or display the app. I removed this part to only have the app displayed at the root and it worked! Now I have to understand how routing works with Agile Toolkit, but this should come easy with your documentation :wink:


glad it worked for you!