3

hopefully simple questions regarding Agle Toolkit. Currently with the below code getting

Error in AJAX response: SyntaxError: Unexpected token <

BaseException

Record ID must be specified, otherwise use loadAny()

page\grant.php

<?php
class page_grant extends Page {
    function init(){
        parent::init();

        $saveForm=$this->add('MVCForm');
        $model=$this->add('Model_Grant')->load($_GET['id']);
        $saveForm->setModel($model);

        $saveForm->addSubmit();

        $saveForm->onSubmit(function($saveForm){
            $saveForm->update()->js()->univ()->successMessage('Grant info saved.')->execute();
        });
    }
}

And Model_Grant:

<?php

class Model_Grant extends Model_Table {
    public $table='minigrant';

    function init() {
        parent::init();
        $this->addField('grant_number');
        $this->addField('grant_name');
        $this->addField('uid');
    }
}

Data is loaded fine but cannot save it back as per above error message.

Omar Mir
  • 1,500
  • 1
  • 19
  • 39

1 Answers1

1

You have to add the stickyGET to the id field:

<?php
class page_grant extends Page {
    function init(){
        parent::init();

        $this->api->stickyGET('id');

        $saveForm=$this->add('MVCForm');
        $model=$this->add('Model_Grant')->load($_GET['id']);
        $saveForm->setModel($model);

        $saveForm->addSubmit();

        $saveForm->onSubmit(function($saveForm){
            $saveForm->update()->js()->univ()->successMessage('Grant info saved.')->execute();
        });
    }
}

Found data on: http://agiletoolkit.org/learn/tutorial/jobeet/day8

Agile Toolkit really needs ONE documentation source with more examples like this because it is easily on the best frameworks I have worked with.

If they (@romaninsh) can do the documentation better then I think It would do better. I imagine they probably need to change the licence from AGPL too but that one matters less to me personally since I am working on OSS.

Omar Mir
  • 1,500
  • 1
  • 19
  • 39