Remove button in detailview with condition in SugarCRM

纵然是瞬间 提交于 2019-12-25 02:20:06

问题


My code :

$GLOBALS['listbutton'] = $this->dv->defs['templateMeta']['form']['buttons'];        
    if ($this->bean->status == 'Converted') {
        unset($this->dv->defs['templateMeta']['form']['buttons'][0]);
    }
    parent::display();

    $GLOBALS['log']->debug("INFOdation log Display");        
    $this->dv->defs['templateMeta']['form']['buttons'] = $GLOBALS['listbutton'];

But when status =='New' , the edit button still hide. Could you help me. I only want edit button hide when status == 'Converted', other status it has to apperance.


回答1:


You could hide the Button with Javascript.

in the detailviewdefs.php include your script

'includes' => 
 array (
  0 => 
  array (
    'file' => 'custom/modules/Leads/button_hide.js',
  ),
 ),

With something like:

SUGAR.util.doWhen("typeof $ != 'undefined'", function(){
    if($(#status).val() == "Converted")$('#delete_button').parent().hide(); 
});

(SUGAR.util.doWhen ist the SugarCrm onload if ajax ist enabled)

if the Field status is not in your view you will need to add a hidden field in detailviewdefs.php and set the value with smarty code like:

<input type="hidden" id="status" value="{$fields.status.value}">


来源:https://stackoverflow.com/questions/22213869/remove-button-in-detailview-with-condition-in-sugarcrm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!