I'v setup a many to many relation with intermediate table.
It is used to create/view watchlists for funds.
ATK4.2.5
But now I'd like to create a drowpdown with watchlists, add the condition to the model and automaticaly reload the grid. Didn't find a "simple" example so far searching docs, questions or demos.. Again it must be easy... but somehow I've been trying for few hours without result.
class Model_FundWatchlist extends Model_Table {
public $table="fundwatchlist";
function init(){
parent::init();
$this->hasOne('Watchlist');
$this->hasOne('Fund');
//$this->addCondition('watchlist_id',1);
}
}
class page_fundwatchlist extends Page {
function init(){
parent::init();
//debug
//$this->add('Text')->set(json_encode($_GET));
$f = $this->add('Form');
$wl = $f->addField('dropdown','watchlist','Watchlist')
->setEmptyText('Select a list');
$wl->setModel('Watchlist');
$wl->js('change', $f->js()->trigger('submit'));
$c = $this->add('CRUD',array('allow_add'=>true,
'allow_edit'=>true,
'allow_delete'=>true,
'frame_options'=>array('width'=>'600px')));
$c->setModel('Fundwatchlist');
//on change dropbox add $c->addCondition('watchlist_id',$_GET['watchlist_id']);
if ($c->grid) {
$c->grid->addQuickSearch(array('fund'));
$c->grid->addPaginator(25);
}
}
}