Hi,
I want to change the address fields as per my requirement and display it like:
At the place of Floor i need my custom fields.
can any one please help me.
Hi,
I want to change the address fields as per my requirement and display it like:
At the place of Floor i need my custom fields.
can any one please help me.
Hi,
Can any one please help me i am not able to do it.
how can i add fields to address combo
Hi Ajit Agarw
That's how I do it:
As M Waleed said, you must modify the files in include/SugarFields/Fields/Address.
You can and should do it by copying them in custom/include/SugarFields/Fields/Address and start modifying them there.
For instance, I created in Studio a field called billing_address_c_autonoma_c that I wanted to add to the other address fields. That's how I included it in the EditView.tpl file:
<script type="text/javascript" src='{sugar_getjspath file="include/SugarFields/Fields/Address/SugarFieldAddress.js"}'></script>
<fieldset id='{{$displayParams.key}}_address_fieldset'>
<legend>{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS' module='{{$module}}'}</legend>
<table border="0" cellspacing="1" cellpadding="0" class="edit" width="100%">
<!-- START --- CUSTOM -->
<tr>
<td id="{$fields.{{$displayParams.key}}_address_country.name}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{$fields.{{$displayParams.key}}_address_country.name}">{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS_COUNTRY' module='{{$module}}'}:</label>
{if $fields.{{$displayParams.key}}_address_country.required || $fields.{{$displayParams.key}}_address_country.name|lower|in_array:$displayParams.required}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<select name="{$fields.{{$displayParams.key}}_address_country.name}" width="{{$displayParams.size|default:30}}" id="{$fields.{{$displayParams.key}}_address_country.name}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$displayParams.key}}_address_country.value) && $fields.{{$displayParams.key}}_address_country.value != ''}
{html_options options=$fields.{{$displayParams.key}}_address_country.options selected=$fields.{{$displayParams.key}}_address_country.value}
{else}
{html_options options=$fields.{{$displayParams.key}}_address_country.options selected=$fields.{{$displayParams.key}}_address_country.default_value}
{/if}
</select>
</td>
</tr>
<tr>
<td id="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}">{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS_C_AUTONOMA' module='{{$module}}'}:</label>
{if $fields.{{$displayParams.key}}_address_c_autonoma_c.required || $fields.{{$displayParams.key}}_address_c_autonoma_c.name|lower|in_array:$displayParams.required}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<select name="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}" width="{{$displayParams.size|default:30}}" id="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$displayParams.key}}_address_c_autonoma_c.value) && $fields.{{$displayParams.key}}_address_c_autonoma_c.value != ''}
{html_options options=$fields.{{$displayParams.key}}_address_c_autonoma_c.options selected=$fields.{{$displayParams.key}}_address_c_autonoma_c.value}
{else}
{html_options options=$fields.{{$displayParams.key}}_address_c_autonoma_c.options selected=$fields.{{$displayParams.key}}_address_c_autonoma_c.default_value}
{/if}
</select>
<input type="hidden" name="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}">
</td>
</tr>
<!-- END --- CUSTOM -->
{{foreach from=$displayParams.fields item=field}}
{{if not strpos($field.name, 'country')}}
<tr>
<td id="{{$field.name}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{{$field.name}}">{sugar_translate label='{{$field.vname}}' module='{{$module}}'}:</label>
{{if $field.required || $field.name|lower|in_array:$displayParams.required}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{{/if}}
</td>
<td>
{{if strpos($field.name, 'address_street')}}
<textarea id="{{$field.name}}" name="{{$field.name}}" maxlength="{{$field.len|default:$displayParams.maxlength}}" rows="{{$displayParams.rows|default:4}}" cols="{{$displayParams.cols|default:60}}" tabindex="{{$tabindex}}">{$fields.{{$field.name}}.value}</textarea>
{{else}}
{{if strpos($field.name, 'country')}}
<select name="{{$field.name}}" width="{{$displayParams.size|default:30}}" id="{{$field.name}}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$field.name}}.value) && $fields.{{$field.name}}.value != ''}
{html_options options=$fields.{{$field.name}}.options selected=$fields.{{$field.name}}.value}
{else}
{html_options options=$fields.{{$field.name}}.options selected=$fields.{{$field.name}}.default_value}
{/if}
</select>
{{else}}
<input type="text" name="{{$field.name}}" id="{{$field.name}}" size="{{$displayParams.size|default:30}}" maxlength="{{$field.len|default:$displayParams.maxlength}}" value='{$fields.{{$field.name}}.value}' tabindex="{{$tabindex}}">
{{/if}}
{{/if}}
</td>
</tr>
{{/if}}
{{/foreach}}
{{if $displayParams.copy}}
<tr>
<td scope='row' NOWRAP>
{sugar_translate label='LBL_COPY_ADDRESS_FROM_LEFT' module=''}:
</td>
<td>
<input id="{{$displayParams.key}}_checkbox" name="{{$displayParams.key}}_checkbox" type="checkbox" onclick="{{$displayParams.key}}_address.syncFields();">
</td>
</tr>
{{else}}
<tr>
<td colspan='2' NOWRAP> </td>
</tr>
{{/if}}
</table>
</fieldset>
<script type="text/javascript">
SUGAR.util.doWhen("typeof(SUGAR.AddressField) != 'undefined'", function(){ldelim}
{{$displayParams.key}}_address = new SUGAR.AddressField("{{$displayParams.key}}_checkbox",'{{$displayParams.copy}}', '{{$displayParams.key}}');
{rdelim});
</script>
I just recommend you to study a bit this code and then perform your own modifications.
The result of this modifications after a Quick Repair and Rebuild is the following:
Hi Ajit Agarw
That's how I do it:
As M Waleed said, you must modify the files in include/SugarFields/Fields/Address.
You can and should do it by copying them in custom/include/SugarFields/Fields/Address and start modifying them there.
For instance, I created in Studio a field called billing_address_c_autonoma_c that I wanted to add to the other address fields. That's how I included it in the EditView.tpl file:
<script type="text/javascript" src='{sugar_getjspath file="include/SugarFields/Fields/Address/SugarFieldAddress.js"}'></script>
<fieldset id='{{$displayParams.key}}_address_fieldset'>
<legend>{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS' module='{{$module}}'}</legend>
<table border="0" cellspacing="1" cellpadding="0" class="edit" width="100%">
<!-- START --- CUSTOM -->
<tr>
<td id="{$fields.{{$displayParams.key}}_address_country.name}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{$fields.{{$displayParams.key}}_address_country.name}">{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS_COUNTRY' module='{{$module}}'}:</label>
{if $fields.{{$displayParams.key}}_address_country.required || $fields.{{$displayParams.key}}_address_country.name|lower|in_array:$displayParams.required}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<select name="{$fields.{{$displayParams.key}}_address_country.name}" width="{{$displayParams.size|default:30}}" id="{$fields.{{$displayParams.key}}_address_country.name}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$displayParams.key}}_address_country.value) && $fields.{{$displayParams.key}}_address_country.value != ''}
{html_options options=$fields.{{$displayParams.key}}_address_country.options selected=$fields.{{$displayParams.key}}_address_country.value}
{else}
{html_options options=$fields.{{$displayParams.key}}_address_country.options selected=$fields.{{$displayParams.key}}_address_country.default_value}
{/if}
</select>
</td>
</tr>
<tr>
<td id="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}">{sugar_translate label='LBL_{{$displayParams.key|upper}}_ADDRESS_C_AUTONOMA' module='{{$module}}'}:</label>
{if $fields.{{$displayParams.key}}_address_c_autonoma_c.required || $fields.{{$displayParams.key}}_address_c_autonoma_c.name|lower|in_array:$displayParams.required}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<select name="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}" width="{{$displayParams.size|default:30}}" id="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$displayParams.key}}_address_c_autonoma_c.value) && $fields.{{$displayParams.key}}_address_c_autonoma_c.value != ''}
{html_options options=$fields.{{$displayParams.key}}_address_c_autonoma_c.options selected=$fields.{{$displayParams.key}}_address_c_autonoma_c.value}
{else}
{html_options options=$fields.{{$displayParams.key}}_address_c_autonoma_c.options selected=$fields.{{$displayParams.key}}_address_c_autonoma_c.default_value}
{/if}
</select>
<input type="hidden" name="{$fields.{{$displayParams.key}}_address_c_autonoma_c.name}">
</td>
</tr>
<!-- END --- CUSTOM -->
{{foreach from=$displayParams.fields item=field}}
{{if not strpos($field.name, 'country')}}
<tr>
<td id="{{$field.name}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for="{{$field.name}}">{sugar_translate label='{{$field.vname}}' module='{{$module}}'}:</label>
{{if $field.required || $field.name|lower|in_array:$displayParams.required}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{{/if}}
</td>
<td>
{{if strpos($field.name, 'address_street')}}
<textarea id="{{$field.name}}" name="{{$field.name}}" maxlength="{{$field.len|default:$displayParams.maxlength}}" rows="{{$displayParams.rows|default:4}}" cols="{{$displayParams.cols|default:60}}" tabindex="{{$tabindex}}">{$fields.{{$field.name}}.value}</textarea>
{{else}}
{{if strpos($field.name, 'country')}}
<select name="{{$field.name}}" width="{{$displayParams.size|default:30}}" id="{{$field.name}}" title="{{$vardef.help}}" tabindex="{{$tabindex}}" {{if isset($displayParams.script)}}{{$displayParams.script}}{{/if}}>
{if isset($fields.{{$field.name}}.value) && $fields.{{$field.name}}.value != ''}
{html_options options=$fields.{{$field.name}}.options selected=$fields.{{$field.name}}.value}
{else}
{html_options options=$fields.{{$field.name}}.options selected=$fields.{{$field.name}}.default_value}
{/if}
</select>
{{else}}
<input type="text" name="{{$field.name}}" id="{{$field.name}}" size="{{$displayParams.size|default:30}}" maxlength="{{$field.len|default:$displayParams.maxlength}}" value='{$fields.{{$field.name}}.value}' tabindex="{{$tabindex}}">
{{/if}}
{{/if}}
</td>
</tr>
{{/if}}
{{/foreach}}
{{if $displayParams.copy}}
<tr>
<td scope='row' NOWRAP>
{sugar_translate label='LBL_COPY_ADDRESS_FROM_LEFT' module=''}:
</td>
<td>
<input id="{{$displayParams.key}}_checkbox" name="{{$displayParams.key}}_checkbox" type="checkbox" onclick="{{$displayParams.key}}_address.syncFields();">
</td>
</tr>
{{else}}
<tr>
<td colspan='2' NOWRAP> </td>
</tr>
{{/if}}
</table>
</fieldset>
<script type="text/javascript">
SUGAR.util.doWhen("typeof(SUGAR.AddressField) != 'undefined'", function(){ldelim}
{{$displayParams.key}}_address = new SUGAR.AddressField("{{$displayParams.key}}_checkbox",'{{$displayParams.copy}}', '{{$displayParams.key}}');
{rdelim});
</script>
I just recommend you to study a bit this code and then perform your own modifications.
The result of this modifications after a Quick Repair and Rebuild is the following:
Hi
Thank You for helping me.