问题
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