Make Address Field readonly

Hi,
traditional field is easy…just put type=readonly.

WHat about address filed that has already a property type=address?

Thank you

You should not set the type as readonly, that’s bad practice. You should just add it to the end of the tag, as in: this example.

ok thank you…but where.

I meant about editviewdef for example.

Which file are involved in this case?

Thabk you

Hi,

You can add following line in top of your editviewdefs.php in your module.

display parameters to field which you make readonly as following.

‘displayParams’ => array (
‘readonly’ => true,
)

This will help you.

mmmm…not luck…seems it doesn’t works.

let’s tak ethis example in ediviewdef on custom account module:

array (
0 =>
array (
‘name’ => ‘billing_address_street’,
‘label’ => ‘LBL_BILLING_ADDRESS’,
‘type’ => ‘address’,
‘displayParams’ =>
array (
‘readonly’ => true,
‘key’ => ‘billing’,
),
),
1 =>
array (
‘name’ => ‘shipping_address_street’,
‘label’ => ‘LBL_SHIPPING_ADDRESS’,
‘type’ => ‘address’,
‘displayParams’ =>
array (
‘readonly’ => true,
‘key’ => ‘shipping’,
),
),
),

any suggestion?

Thank you

Hi,

Did you try using Quick Repair from administration panel?

Yes…with no success

Hi,

I am giving you two way to get your result.

  1. Using js.

  2. Direct add readonly in file.

  3. Using js.

in js file

$(document).ready(function(){
var addressFieldArray = new Array(‘street’,‘city’,‘state’,‘postalcode’,‘country’);
for(var i = 0;i<addressFieldArray.length;i++){
$(’#primary_address_’+addressFieldArray[i]).attr(‘readonly’,true);
}
});

include this js file in view.edit.php or you can put this code in view,edit.php in display function too.
like:–

public function display(){
echo "";
parent::display();
}

  1. add readonly in your html in en_us.EditView.tpl and will get your result.
    path:-- custom/include/SugarFields/Fields/Address/en_us.EditView.tpl
    if not exists then copy from main.

check this and let us know if it helps you.

Thanks.

Thank you.
I will test it and let you know.

Thanks again