addSelectable on CRUD grid - not returning values

38 views
Skip to first unread message

The Black Pig

unread,
Nov 20, 2012, 8:10:22 AM11/20/12
to agile-too...@googlegroups.com
Hi all,

I'm trying to pass the values from the checkboxes created by addSelectable to another form in a dialog.

However, when I test for the value of the the 'selectable' field it is always empty.

I have tried 2 different methods to get  handle on the ids

Method 1 - via a form submit:
class page_land extends Page {
    function init(){
        parent::init();
    
$c = $this->add('CRUD','Advanced');
        $c->setModel('Land');

        $f = $c->add('Form',null,null,array('form_empty'));
        $f->addField('line','ids');

        if ($c->grid){
            $c->grid->addSelectable('ids');

            if ($c->grid->addButton('Add Notes')->isClicked()) {
                $f->js(true)->submit()->execute();
            }

             $f->onSubmit(function($f) use ($c) {
                $ids = $f->get('ids');
                $f->js()->univ()->alert($ids)->execute(); //ids is always empty
            });

            }
        }
}

Method 2 - just try and grab the form values
class page_land extends Page {
    function init(){
        parent::init();
    
$c = $this->add('CRUD','Advanced');
        $c->setModel('Land');

        $f = $c->add('Form',null,null,array('form_empty'));
        $f->addField('line','ids');

        if ($c->grid){
            $c->grid->addSelectable('ids');

            if ($c->grid->addButton('Add Notes')->isClicked()) {
                $ids = $f->get('ids');
                $this->js()->univ()->alert($ids)->execute();
            }
        }
}

Thanks
Stuart

The Black Pig

unread,
Nov 20, 2012, 8:54:05 AM11/20/12
to agile-too...@googlegroups.com

Problem solved I needed to change

$c->grid->addSelectable('ids');

 to 

$c->grid->addSelectable($f->getElement('ids'));

The Black Pig

unread,
Nov 20, 2012, 11:53:00 AM11/20/12
to agile-too...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages