Skip to content

AddressForm container

The AddressForm container creates and edits customer addresses. Merchants build a custom user experience around address management with a pre-built form that minimizes development effort. The form integrates with the Adobe Commerce backend, providing flexible configuration of address attributes, validation, labels, and attribute sorting.

The Addresses container also uses this container.

The following image shows a sample AddressForm container:

AddressForm container

AddressForm container

The AddressForm container provides the following configuration options:

OptionsTypeReq?Description
hideActionFormButtonsbooleanNoControls the visibility of action buttons at the form's bottom. Useful for custom integrations where form submission is managed externally.
formNamestringNoSets the "name" attribute for the form. Defaults to "addressesForm" if not provided. Useful for custom integrations.
showFormLoaderbooleanNoDetermines if a shimmer loader displays instead of the form. Can be used to manage the form’s loading state externally.
showSaveCheckBoxbooleanNoControls visibility of the "Save in address book" checkbox. Useful for implementations where customers can choose to save the address, with form submission managed externally. Enabling this checkbox hides the action buttons automatically (equivalent to setting "hideActionFormButtons" to "true".)
saveCheckBoxValuebooleanNoSets the initial value of the "Save in address book" checkbox.
forwardFormRefHTMLInputElementNoProvides a reference to the form’s DOM element. Useful for custom integrations. This ref also grants access to the "handleValidationSubmit" method to validate form data.
addressFormIdstringNoPasses an address ID when editing an existing address. Used to identify the address to update in Adobe Commerce.
classNamestringNoAllows custom CSS classes to be applied to the form.
addressesFormTitlestringNoControls visibility of the address form title.
inputsDefaultValueSetCustomerAddressesModelNoAllows a set of default values for form inputs.
shippingCheckBoxValuebooleanNoSets the initial value of the "Set as default shipping address" checkbox.
billingCheckBoxValuebooleanNoSets the initial value of the "Set as default billing address" checkbox.
showShippingCheckBoxbooleanNoControls visibility of the "Set as default shipping address" checkbox. The checkbox remains in the form even if hidden, allowing shippingCheckBoxValue to set its value.
showBillingCheckBoxbooleanNoControls visibility of the "Set as default billing address" checkbox. As with the shipping checkbox, it remains present even if hidden.
hasDefaultShippingAddressbooleanNoIndicates whether a default shipping address already exists. Used in the B2B create flow to adjust the default-shipping checkbox behavior.
hasDefaultBillingAddressbooleanNoIndicates whether a default billing address already exists. Used in the B2B create flow to adjust the default-billing checkbox behavior.
isOpenbooleanNoControls the form's visibility.
fieldIdPrefixstringNoPrefixes every form field HTML `id` rendered inside the container. For example, `shipping` produces ids such as `shipping_firstname`. Use different values when rendering two address forms on the same page to prevent duplicate HTML element ids.
onSubmitfunctionNoAllows a custom submit handler to override the default form submission behavior.
slots.AddressFormActionsAddressFormActionsContextNoProvides an option to override the call-to-action buttons for the address form.
slots.AddressFormInputsAddressFormInputsContextNoAllows additional custom inputs or HTML elements at the form’s bottom.
slots[`AddressFormInput_${attribute.code}`]slotNoAllows overriding input used for a particular form field. Example slot names: “AddressFormInput_firstname”, “AddressFormInput_street”.
onCloseBtnClickfunctionNoProvides an option to pass a callback to close the form, useful for custom implementations where the form appears in a modal and should close upon successful submission.
onSuccessfunctionNoCallback that runs on successful form submission. The response includes `addressUid` for proper address identification.
onErrorfunctionNoCallback that runs when an error occurs during submission. Receives the error as a parameter.
onChangefunctionNoCallback that runs on each form change, receiving form data as a parameter. Use for custom integrations.
isB2BFlowbooleanNoRoutes form submission through the company-address APIs and enables B2B-specific validation rules.
enforceB2BPermissionsbooleanNoEnforces company-role permissions for create, edit, and set-default actions in the B2B flow. Disable only for checkout-oriented scenarios.
permissionsCompanyAddressPermissionsNoThe resolved company-address permissions that control which address actions the customer can perform, such as create, edit, delete, and set default.

HTMLInputElement usage sample:

const formRef = { current: null };
provider.render(AddressForm, {
forwardFormRef: formRef,
})(containerWrapper);
const isFormValid = formRef.current.handleValidationSubmit();
const formData = inputRef.current.formData;
return {
handleValidationSubmit,
formData: normalizeGetAddressData(modifyFormRef, true),
isDataValid,
};

isDataValid is a boolean value that indicates whether the form has been validated without an explicit submit action.

inputsDefaultValueSet sample payload:

inputsDefaultValueSet: {
city: 'City',
company: '',
countryCode: 'AR',
region: {
regionCode: 'AR-H',
regionId: 1579,
},
telephone: '123456789',
vatId: '999',
postcode: '12345',
street: 'Street One',
streetMultiline_2: 'Street Two',
}

The following example renders the AddressForm container with custom configurations:

provider.render(AddressForm, {
addressesFormTitle: 'Address form title',
addressId: '',
isOpen: true,
shippingCheckBoxValue: true,
billingCheckBoxValue: true,
showShippingCheckBox: true,
showBillingCheckBox: true,
onChange: (values, inputValue) => {
console.log('allValues', values);
console.log('inputValue', inputValue);
},
onSuccess: () => {
console.log('onSuccess');
},
onError: () => {
console.log('onError');
},
})(containerWrapper);