i want to remove this street, city , postal and country field completely
Hi, @Abhishek Surve
Since we're talking about <lightning-input-address>, you can configure this component through the template code.
For example:
<template>
<lightning-card title="Add new Address">
<div class="slds-p-around_medium">
<lightning-input-address
address-label="Address"
street-label="Street"
city-label="City"
province-label="State/Province"
postal-code-label="Zip/Postal Code"
country-label="Country"
required
value={address}
onchange={handleChange}>
</lightning-input-address>
</div>
</lightning-card>
</template>
Here we can see that there are fields like street-label, city-label, province-label, etc.
You can delete or edit them according to your needs.
Also, don’t forget to make changes in the JS file, which in turn receives information from all these fields.
So, if you delete a field in the HTML markup, you also need to remove the request for information from this field in the JS markup.
import { LightningElement } from 'lwc';
export default class AddressForm extends LightningElement {
address = {
street: '',
city: '',
province: '',
postalCode: '',
country: ''
};
handleChange(event) {
const field = event.target.name;
this.address[field] = event.target.value;
}
}
Sincerely,
Mykhailo Vdovychenko
Bringing Cloud Excellence with IBVCLOUD OÜ