Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AddressController.php #34152

Closed
wants to merge 12 commits into from
14 changes: 11 additions & 3 deletions controllers/front/AddressController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,22 @@ public function init()
public function postProcess()
{
$this->context->smarty->assign('editing', false);
$id_address = (int) Tools::getValue('id_address');
// Initialize address if an id exists

$params = Tools::getAllValues();
$id_address = isset($params['id_address']) ? (int) $params['id_address'] : 0;
metacreo marked this conversation as resolved.
Show resolved Hide resolved

// Initialize address if an id exists and prevent fill form with default country second time.
if ($id_address) {
$this->address_form->loadAddressById($id_address);
// If this is only form request. Adding param id_country for CustomerAddressForm class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a hack honestly, I'll have to look deeper since I'm not sure if we should have to do that there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpodemski no... this param needs only for correct form fill.

if (!Tools::isSubmit('submitAddress')) {
$address = new Address($id_address, $this->context->language->id);
$params['id_country'] = $address->id_country;
}
}

// Fill the form with data
$this->address_form->fillWith(Tools::getAllValues());
$this->address_form->fillWith($params);

// Submit the address, don't care if it's an edit or add
if (Tools::isSubmit('submitAddress')) {
Expand Down