phpatk4

How to define new Model in ATK4


From: http://agiletoolkit.org/learn/understand/model/add

class Model_MyModel extends Model_Table {

    function init(){
        parent::init();
        $this->addField('name');
    }
}

From: http://agiletoolkit.org/intro/models

class Model_MyModel extends Model_Table {

    function defineFields(){
        parent::defineFields();
        $this->addField('name');
    }
}

Which is correct? What's the difference?


Solution

  • Agile Data has been refactored into a separate framework: http://git.io/ad

    The up-to-date way for defining the model is documented here: http://agile-data.readthedocs.io/en/develop/model.html


    using the init() method is the right one. defineField is old way and was changed in favor of "init" due to consistency.

    I will update the pages accordingly.