如何在 SugarCRM 中为自定义视图创建布局


How to create a Layout for a custom view in SugarCRM

我创建了一个完全自定义的视图,我希望此视图仅以编辑视图格式显示某些字段,以便我可以更新记录。但此视图与普通的编辑视图不同。如何向此视图添加自定义元数据文件,以允许我定义所需的表单和字段?该视图绑定到自定义按钮,当前仅显示"作品"。到目前为止,这只需要了解如何定义布局即可。

控制器:

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class CustomCasesController extends SugarController {
function action_resolve_Case() {
    $this->view = 'resolve_case';
}
}

观点 :

if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
require_once('include/MVC/View/SugarView.php');

class CasesViewresolve_case extends SugarView {
public function CasesViewresolve_case() {
    parent::SugarView();
}
function preDisplay() {
    parent::preDisplay();
}
public function display() {
   // include ('test.php');
    echo "works";
}
}

老了,但仍然可以帮助某人...

您可以:

  1. 在显示功能内工作。您在此处执行或回显的所有内容都将显示在 Sugar 应用程序主屏幕(导航栏、页脚等(中,因此它看起来是原生的。

  2. 直接在控制器内部工作,并回显所有内容。

使用要编辑的字段构建表单,并在控制器中将函数作为操作,您可以在其中使用 bean->save(( 方法获取 POST 结果。

<form name="whatever" method="POST" action="index.php?module=Contacts&action=yourcustomaction">

前任:

    `$contact = new Contact();
     $contact->retrieve("{$_REQUEST['contactId']}"); 
     //be sure to send the id in the button/link to the view
     $contact->first_name =$_POST['first_name'];
     $contact->last_name =$_POST['last_name'];
     .....
     $contact->save();`

不是很优雅,但我知道的唯一其他选择是使用我不熟悉的聪明模板。

如果有人有更好的解决方案,请发布它。