Hello,
i’m coding a custom action in list view but i’m a bit confused regarding how to pass selected items into a new view with a custom template.
This is what i’ve done so far.
1. Create custom Action Button in ListView that points to custom Action
class sugo_ComputersViewList extends ViewList
{
/**
* @see ViewList::preDisplay()
/
public function preDisplay()
{
parent::preDisplay();
$this->lv->actionsMenuExtraItems[] = $this->addMenuItem();
}
/*
* @return string HTML
*/
protected function addMenuItem()
{
global $app_strings;
return <<<EOHTML
Create Job
EOHTML;
}
}
2. Write my own Controller with test action
class sugo_ComputersController extends SugarController
{
function action_test(){
$GLOBALS[‘log’]->fatal(‘Am in Controller’);
//var_dump(METHOD);
$this->view = “test”;
if ( !empty($_REQUEST[‘uid’]) ) {
$recordIds = explode(’,’,$_REQUEST[‘uid’]);
foreach ( $recordIds as $recordId ) {
$bean = SugarModule::get($_REQUEST[‘module’])->loadBean();
$bean->retrieve($recordId);
echo “Sent Record ID {$bean->id}, name “.$bean->get_summary_text().””;
}
}
}
}
3. Write a custom action view that should render my custom template
class sugo_ComputersViewtest extends SugarView
{
public function preDisplay() {
$this->dv->tpl = 'include/ListView/ListViewGeneric.tpl';
}
public function display()
{
echo '<h1>Some other View</h1>';
$GLOBALS['log']->fatal('Am in View');
}
}
Attached a screenshot with above code.
What i would achieve is passing selected items from listview to a test action intercepted by controller…
then render everything in the test view with my custom template.
First time for me so i’m a bit confused on this.
Appreciate any help.
Thank you very much
Reards