It never fails, I can work on something for hours, and 5 minutes after I pose a question, I figure it out. Well, at least maybe I’ll help someone else…
First you have to create a custom view.edit.php in /custom/modules/NAME OF MODULE/views
In this case I’m passing 3 things over to editview, readonly, $isAdministrator and the $app list.
class OpportunitiesViewEdit extends ViewEdit
{
public function __construct()
{
parent::__construct();
$this->useForSubpanel = true;
$this->useModuleQuickCreateTemplate = true;
}
public function display()
{
global $app_list_strings, $current_user;
// Check if the user is an administrator
$isAdministrator = $current_user->is_admin;
// Set the $readOnly variable based on the user's administrator status
$readOnly = $isAdministrator ? '' : 'readonly = "readonly"';
// Assign $readOnly to Smarty template
$this->ev->ss->assign('readOnly', $readOnly);
//Assign $isAdministrator to Smarty template
$this->ev->ss->assign('isAdministrator', $isAdministrator);
// Pass app_list_strings to Smarty template
$this->ev->ss->assign('APP_LIST', $app_list_strings);
parent::display(); // Call the parent display function to render the view
}
}
Then in editviewdefs.php, you can construct your custom code like this:
'customCode' => '{if $isAdministrator}
@@FIELD@@
{elseif $fields.sales_stage.value eq "Closed Won" || $fields.sales_stage.value eq "Closed Lost"}
<span>{$APP_LIST.sales_stage_dom[$fields.sales_stage.value]}</span>
{else}
@@FIELD@@
{/if}',