How to create a custom view of type Edit in Sugar CRM or Suite CRM
How to create a custom view of type Edit in SugarCRM CE 6.5 or SuiteCRM.
In SugarCRM CE 6.5 or in SuiteCRM there is the standard EditView mask that allows you to insert/modify an object of a specific module, there is also the QuickCreate that can be used to quickly insert an object.
These two masks are standard and easy to manage with Studio.
Sometimes, however, it can be useful to create a custom view of type Edit to manage personalized insert/modify to be used in specific cases.
To obtain this you need 3 steps:
create the view in
custom/modules/
/views/view. .php;
create the view in
custom/modules/
/controller.php;
define the view in
custom/modules/
/metadata/ viewdefs.php
After a “Quick Repair and Rebuild”, you are allowed to call the view with a link like this
/index.php?module= &action= &record=
eventually followed with other parameters you may need (managed in the file view.
Let’s start with the file
custom/modules/
/views/view. .php:
View
extends ViewEdit { public function preDisplay() {
$this->type = ‘‘;
parent::preDisplay();
$this->ev->view = ‘View’;
}public function display() {
parent::display();
}}
?>
Let’s examine the file
custom/modules/
/controller.php:
Controller extends SugarController {
public function action_
() {
$this->view = ‘‘;
}}
?>
Finally the file
custom/modules/
/metadata/ viewdefs.php
that will have the same syntax of the file
custom/modules/
/metadata/editviewdefs.php:
‘;
$_object_name = ‘‘;
$viewdefs [$module_name] =
array (
‘EditView’ =>
array (
‘templateMeta’ =>
array (
‘form’ =>
array (
‘buttons’ =>
array (
0 => ‘SAVE’,
1 => ‘CANCEL’,
),
‘headerTpl’ => ‘include/EditView/header.tpl’,
‘footerTpl’ => ‘include/EditView/footer.tpl’,
),
‘maxColumns’ => ‘2’,
‘widths’ =>
array (
0 =>
array (
‘label’ => ’10’,
‘field’ => ’30’,
),
1 =>
array (
‘label’ => ’10’,
‘field’ => ’30’,
),
),
‘useTabs’ => false,
‘tabDefs’ =>
array (
‘DEFAULT’ =>
array (
‘newTab’ => false,
‘panelDefault’ => ‘expanded’,
),
),
),
‘panels’ =>
array (
‘default’ =>
array (
0 =>
array (
0 => ‘name’
),
),
),
),
);
?>
In this example we put only the field “name”, but of course you can set it similarly to the file
custom/modules/
/metadata/editviewdefs.php