Hi guys,
i am trying to define a new view like this(it is just a test).
require_once('include/MVC/View/SugarView.php');
class CDZ_Contracts_MobileViewMigrate extends SugarView
{
public function __construct() {
parent::SugarView();
}
public function preDisplay() {
$this->dv->tpl = 'modules/CDZ_Contracts_Mobile/caderize/templates/migrate.tpl';
}
public function display() {
global $db;
global $sugar_custom;
//global $current_user;
// or use below(same way)
$cUser = $GLOBALS['current_user'];
if(!$cUser->is_admin) {
echo "You do not have permission to view this page.";
return;
}
$smarty = new Sugar_Smarty();
$smarty->assign('message', $this->view_object_map['message']);
parent::display();
$smarty->display($this->dv->tpl);
}
In the smarty tpl i need to have a form with just few fields for example assigned_user_id and a submit button.
What i would do is to prepare smarty tpl to render just like a traditional ‘assigned to’ field so i though the best way is to attach a customized viewdefs just like editviewdefs but reduced based on my needs(see screenshot).
Thank you for the Hint.
In order to work i had to register the new view in Action View Map in custom/extension/module etc.
Due to the fact it is a brand new module built on module builder, is there a way to register the view inside the module itself without using custom action view map?
I’ve done a test based on your solution and it works.
However the only strange behavior i’ve found is about auto completion feature of relate field that doesn’t fire.
My test was:
1 . Create controller action that points to new view
2. Create new view that have custom viewdefs(exact copy of editviewdef) and point to new tpl(exact copy of EditView.tpl) like this:
public function preDisplay() {
//#!@ # Include JS file with heredoc notation
$js = <<<JS
<script src="modules/CDZ_Contracts_Mobile/caderize/js/cdz_modal.js"></script>
JS;
echo $js;
$metadatafile = "modules/CDZ_Contracts_Mobile/metadata/bulkstorageeditviewdefs.php";
$this->ev = new EditView();
$this->ev->ss =& $this->ss;
$this->ev->view = "mynewview";
$this->ev->ss->assign("message", "CIAO MONDO");
$this->ev->setup($this->module, $this->bean, $metadatafile, 'modules/CDZ_Contracts_Mobile/caderize/templates/migrate.tpl', true, 'mynewvieweditviewdefs');
}
As mentioned all works fine excpet for auto completion in assigned user for example, and the only way to assign a new user is to click the button next to relate in order to open popup search.
Seems that some js is not fired…tried to debug with no luck…