I'm a beginner and searched documentation, but can't find this how to do this:
I have two tables, admin and application. Admin can have many applications.
ADMIN:
class Model_Admin extends Model_Table {
public $entity_code='admin';
function init(){
parent::init();
$this->addField('name');
$this->addField('email');
$this->addField('password')->type('password');
$this->addField('active')->type('boolean')->system(true);
$this->addField('super')->type('boolean')->system(true);
$this->addField('created')->type('timestamp')->defaultValue($this->dsql()->expr('now()'))->system(true);
$this->addField('updated')->type('timestamp')->system(true);
$this->hasMany('Application','admin_id');
//$this->hasOne('Application');
$this->addHook('beforeSave',function($m){
$m['updated']=$m->dsql()->expr('now()');
});
}
}
APPLICATION:
class Model_Application extends Model_Table {
public $entity_code='application';
function init(){
parent::init();
$this->addField('name');
$this->addField('fbid');
$this->addField('fbsecret');
$this->addField('active')->type('boolean')->system(true);
$this->addField('created')->type('timestamp')->system(true);
$this->addField('updated')->type('timestamp')->system(true);
}
}
First question, when I generate SQL code (/generate.html) it doesn't produce anything for one to many relationship. Second, on a page I add CRUD:
$this->add('CRUD')->setModel('Admin');
But there is no hint for any one to many. I would expect it on the add button form, but also there is nothing?
What I want is, that I can add admin, and select which applications belong to it?