We can take this a step further and add assignable to the mix. An assignable module would be one that can be assigned to users. Although this isn't used by every module, many modules do let you assign records to users. SugarObject interfaces allow us to add assignable to modules we wish to let users assign records.
• action_save - this would be the broadest specification and would give the user full control over the save process.
• pre_save - a user could override the population of parameters from the form
• post_save - this is where the view is being setup. At this point the developer could set a redirect url, do some post save processing, or set a different viewYou can choose not to provide a custom action method as defined above, and instead specify your mappings of actions to files in $action_file_map. Take a look at include/MVC/Controller/action_file_map.php as an example:
Here the developer has the opportunity to map an action to a file. For example Sugar uses a generic SubPanel file for handling subpanel actions. You can see above that there is an entry mapping the action ‘subpanelviewer' to include/SubPanel/SubPanelViewer.php.For example if a request comes in for DetailView this is how the controller will handle that requestViews are responsible for the display of information to the browser. Views are not just limited to HTML data, you can have it send down JSON encoded data as part of the view or any other structure you wish. As with the controllers there is a default class called SugarView which implements a lot of the basic logic for views such as handling of headers and footers.As a developer if you want to create a custom view you would place a view.<view_name>.php file in a views/ subdirectory within the module. For example, for the DetailView you would create a file name view.detail.php and place this within the views/ subdirectory within the module. If a views subdirectory does not exist, you should create one.In the file you should create a class named: <Module>View<ViewName>. For example, for a list view within the Contacts module the class would be ContactsViewList. Note the first letter of each word is uppercase and all other letters are lowercase.You can extend the class from SugarView, the parent class of all views, or you can extend from an existing view. For example extending from the out of the box list view can leverage a lot of the logic that has already been done for displaying a list view.
• preDisplay() - This performs preprocessing within a view. When developing a new view you should not worry about this method. It is only relevant for extending existing views. For example, the include/MVC/View/views/view.edit.php file uses this and allows developers who wishes to extend this view to leverage all of the logic done in preDisplay() and either override the display() method completely or within your own display() method call parent::display().
• display() - This performs the actual displaying of the data to the screen. This is where the logic to display output to the screen should be placed.The ViewFactory class tries to load the view for view in this sequence and will use the first one it finds:The Sugar MVC provides developers with granular control how the screen looks when their view is rendered. Each view can have a config file associated with it. So for the example above, a developer would place a view.edit.config.php within the views/ subdirectory and when the EditView is rendered this config file will be picked up. When loading the view ViewFactory class will merge the view config files from the following possible locations with precedence order (high to low):
To illustrate this process, let’s take a look at how the ‘popup’ action is processed. In this case the system will go to the actions entry within the view_config and determine the proper configuration. Also if the request contains the parameter to_pdf and is set to be true then it will automatically cause the show_all configuration parameter to be set false, which means do not show any of the options.
Copyright 2004-2008 SugarCRM Inc.
Product License