Add district into address

Let’s go to the new Manual

I’m going to assume that the module is accounts

1Âș - Go to the folder “
\custom\Extension\modules\Accounts\Ext”
2Âș - Verify that a folder called “Vardefs” already exists
3Âș - If it does not exist, create this folder


4Âș - Within this folder create a file called “billing_address_district.php”
5Âș - In the file place the following code

<?php
$dictionary['Account']['fields']['billing_address_district'] = 
	 array (
	'required' => false,
	'name' => 'billing_address_district',
	'vname' => 'LBL_BILLING_ADDRESS_DISTRICT',
	'type' => 'varchar',
	'massupdate' => 0,
	'no_default' => false,
	'importable' => 'true',
	'duplicate_merge' => 'disabled',
	'duplicate_merge_dom_value' => '0',
	'audited' => false,
	'reportable' => true,
	'unified_search' => false,
	'merge_filter' => 'disabled',
	'len' => '100',
	'size' => '20',
	'dbType' => 'varchar',
	'inline_edit' => '1',
    );

6Âș - Save and close the file
7Âș - Verify that a folder called “Language” already exists
8Âș - If it does not exist, create this folder
9Âș - Within this folder create a file called “en_us.billing_address_district.php”
10Âș - In the file place the following code

<?php
$mod_strings['LBL_BILLING_ADDRESS_DISTRICT'] = 'Billing Address District:';

11Âș - Save and close the file
12Âș - Now in SuiteCrm go to Admin -> Repair -> Quick Repair and Rebuild and execute the SQL changes
13Âș - Afterwards go to Studio -> Select Accounts -> Fields
14Âș - In This moment you can see that field there
15Âș - Now we need change other files to show this field in Account module
16Âș - Go to “
\include\SugarFields\Fields\Address”
17Âș - Change the file “EditView.tpl”
18Âș - Search for the line with the content

{{assign var="street" value=$displayParams.key|cat:'_address_street'}}

19Âș - Below it, place the following code

{{assign var="district" value=$displayParams.key|cat:'_address_district'}}

20Âș - Below in the file you can see that there is a table where the fields are located, choose the position where you want the district field to be and add the following code

<tr>

<td id="{{$district}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for='{{$district}}'>{sugar_translate label='LBL_ADDRESS_DISTRICT' module='{{$module}}'}:</label>
{if $fields.{{$district}}.required || {{if $district|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$district}}" id="{{$district}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$district}}.value}'  {{if !empty($tabindex)}} tabindex="{{$tabindex}}" {{/if}}>
</td>
</tr>

21Âș - Save and close the file

22Âș - Change the file “en_us.EditView”
23Âș - Search for the line with the content

{{assign var="street" value=$displayParams.key|cat:'_address_street'}}

24Âș - Below it, place the following code

{{assign var="district" value=$displayParams.key|cat:'_address_district'}}

25Âș - Below in the file you can see that there is a table where the fields are located, choose the position where you want the district field to be and add the following code

<tr>

<td id="{{$district}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for='{{$district}}'>{sugar_translate label='LBL_ADDRESS_DISTRICT' module='{{$module}}'}:</label>
{if $fields.{{$district}}.required || {{if $district|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$district}}" id="{{$district}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$district}}.value}'  {{if !empty($tabindex)}} tabindex="{{$tabindex}}" {{/if}}>
</td>
</tr>

26Âș - Save and close the file

27Âș - Change the file “DetailView.tpl”
28Âș - Search for the line with the content

<input type="hidden" class="sugar_field" id="{{$displayParams.key}}_address_street" value="{$fields.{{$displayParams.key}}_address_street.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}">

29Âș - Below it, place the following code

<input type="hidden" class="sugar_field" id="{{$displayParams.key}}_address_district" value="{$fields.{{$displayParams.key}}_address_district.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}">

30Âș - Search for the line with the content

{$fields.{{$displayParams.key}}_address_city.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}

31Âș - Below it, place the following code

{$fields.{{$displayParams.key}}_address_district.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}

32Âș - Save and close the file

33Âș - Change the file “SugarFieldAddress.js”
34Âș - Search for the line with the content

SUGAR.AddressField.prototype={elems:[

35Âș - And Add in the array

,"address_district"

36Âș - Save and close the file
37Âș - Afterwards to an Admin -> Repair -> Quick Repair and Rebuild
38Âș - If you wish the sabe field to shipping adress repeat the operation changind billing to shipping

Be Happy :slight_smile:

1 Like