在我的任务中editviewdefs.php ...这对我有用。该字段是只读的,无法编辑。 有人可以帮我制作'type'=> 'readonly'仅适用于用户角色与'Loan Officer'匹配的情况?
array (
0 => '',
1 =>
array (
'name' => 'processor_signoff_c',
'label' => 'LBL_PROCESSOR_SIGNOFF',
'type' => 'readonly',
),
),
我正在使用6.5.14社区版。
答案 0 :(得分:2)
解决方案如下:
File =>定制/模块/任务/视图/ view.edit.php
/**
* @see SugarView::display()
*/
public function display()
{
if($this->ev->isDuplicate){
$this->bean->status = $this->bean->getDefaultStatus();
} //if
global $current_user;
// check if current user is in specific role
$isEnabledRole = in_array("ITOperation", ACLRole::getUserRoleNames($current_user->id));
if($isEnabledRole)
$this->ev->ss->assign('readOnly', 'readonly = "readonly"');
else
$this->ev->ss->assign('readOnly', '');
parent::display();
}
File =>定制/模块/任务/元数据/ editviewdefs.php
array (
array (
'name' => 'description',
'customCode' => '<input type="text" title="" value="{$fields.description.value}" id="description" name="description" {$readOnly}>',
),
),
),
对于复选框输入类型,则: File =&gt;定制/模块/任务/视图/ view.edit.php
if($isEnabledRole) {
$this->ev->ss->assign('readOnly', 'readonly = "readonly"');
$this->ev->ss->assign('disabled', 'disabled');
} else {
$this->ev->ss->assign('readOnly', '');
$this->ev->ss->assign('disabled', '');
}
File =&gt;定制/模块/任务/元数据/ editviewdefs.php
array (
'name' => 'processor_signoff_c',
'label' => 'LBL_PROCESSOR_SIGNOFF',
'customCode' => '<input type="hidden" name="processor_signoff_c" value="0"><input type="checkbox" id="processor_signoff_c" name="processor_signoff_c" value="1" {if $fields.processor_signoff_c.value == "1"} checked {/if} {$disabled}>',
),
再见 安东尼奥。