Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 3 Module Framework : Metadata Framework : SearchForm Metadata

SearchForm Metadata
The search form layout for each module is defined in the module’s metadata file searchdefs.php. A sample of the Account's searchdefs.php appears as:
<?php
$searchdefs['Accounts'] = array(
'templateMeta' => array('maxColumns' => '3',
'widths' => array('label' => '10', 'field' => '30')),
'layout' => array(
'basic_search' => array(
'name',
'billing_address_city',
'phone_office',
array( 'name' => 'address_street',
'label' => 'LBL_BILLING_ADDRESS',
'type' => 'name',
'group'=> 'billing_address_street'
),
array( 'name'=>'current_user_only',
'label'=>'LBL_CURRENT_USER_FILTER',
'type'=>'bool'
),
),
'advanced_search' => array(
'name',
array( 'name' => 'address_street',
'label' =>'LBL_ANY_ADDRESS',
'type' => 'name'
),
array( 'name' => 'phone',
'label' =>'LBL_ANY_PHONE',
'type' => 'name'
),
'website',
array( 'name' => 'address_city',
'label' =>'LBL_CITY',
'type' => 'name'
),
array( 'name' => 'email',
'label' =>'LBL_ANY_EMAIL',
'type' => 'name'
),
'annual_revenue',
array( 'name' => 'address_state',
'label' =>'LBL_STATE',
'type' => 'name'
),
'employees',
array( 'name' => 'address_postalcode',
'label' =>'LBL_POSTAL_CODE',
'type' => 'name'
),
array('name' => 'billing_address_country',
'label' =>'LBL_COUNTRY',
'type' => 'name'
),
'ticker_symbol',
'sic_code',
'rating',
'ownership',
array( 'name' => 'assigned_user_id',
'type' => 'enum',
'label' => 'LBL_ASSIGNED_TO',
'function' => array('name' =>'get_user_array',
'params' => array(false) )
),
'account_type',
'industry',
),
),
);
?>
The contents of the searchdefs.php file contains an Array variable $searchDefs with one entry. The key is the name of the module as defined in $moduleList array defined in include/modules.php. The value of the $searchDefs array is another array that describes the search form layout and fields.
The 'templateMeta' key points to another array that controls the maximum number of columns in each row of the search form ('maxColumns') as well as layout spacing attributes as defined by 'widths'. In the above example, the generated search form files will allocate 10% of the width spacing to the labels and 30% for each field respectively.
The 'layout' key points to another nested array which defines the fields to display in the basic and advanced search form tabs. Each individual field definition maps to a SugarField widget. Please see the SugarField widget section for an explanation about SugarField widgets and how they are rendered for the search form, DetailView and EditView.
The searchdefs.php file is invoked from the MVC framework whenever a module's list view is rendered (see include/MVC/View/views/view.list.php). Within view.list.php checks are made to see if the module has defined a SearchForm.html file. If this file exists, the MVC will run in classic mode and use the aforementioned 451 include/SearchForm/SearchForm.php file to process the search form. Otherwise, the new search form processing is invoked using include/SearchForm/SearchForm2.php and the searchdefs.php file is scanned for first under the custom/modules/[module]/metadata directory and then in modules/[module]/metadata.
The processing flow for the search form using the metadata subpaneldefs.php file is similar to that of edit and DetailViews.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License