Tips & Pitfalls This section provides some tips you will find useful in using the new MVC and metadata framework and pitfalls that you may run into from the subtle details of the metadata framework that sometimes cause frustration and confusion. We attempt to list some common scenarios encountered and how to address them. Grouping Required Fields Together To group all required fields together all you need to do is set the config to: $GLOBALS['sugar_config']['forms']['requireFirst'] = true; Displaying data on EditViews with a read-only ACL setting $GLOBALS['sugar_config']['showDetailData'] = true; The field value specified in metadata does not appear This usually happens when the user is attempting to specify a variable name in the module's class definition, but not in the vardefs.php file. For example, consider the Products module. In the Products.php class file there is the variable: var $quote_name; If you attempt to retrieve the value in your metadata file as follows: ... array ( 'quote_name', 'date_purchased', ) ... You must also make sure that 'quote_name' is specified in the vardefs.php file: 'quote_name' => array ( 'name' => 'quote_name', 'type' => 'varchar', 'vname' => 'LBL_QUOTE_NAME', 'source'=>'non-db', 'comment' => 'Quote Name' ) This is because the metadata framework populates the Smarty variable $fields using the variables listed in the vardefs.php file. If they are not listed, there is no way for the metadata framework to know for sure which class variables have been set and are to be used. The metadata framework works in conjunction with ACL (Access Control Level) checks in the system and these are tied to fields defined in the vardefs.php file. The field value specified in metadata does not appear but is in vardefs.php This may occur if the variable in the module has not been initialized. The metadata framework invokes the fill_in_additional_detail_fields() method so be sure the values are either set in the constructor or in the fill_in_additional_detail_fields() method. A good strategy to debug the Smarty templates that are generated via the metadata files is to check the cache/modules/<module> directory for the .tpl files (DetailView.tpl, EditView.tpl, etc.). Enable the Developer Mode setting under the Advanced panel found through the Admin ->System Settings link to allow for the Smarty templates to be regenerated on every request.
Copyright 2004-2008 SugarCRM Inc. Product License