Hi,
Mmm. I'm still not clear on your issue.
Suppose this scenario:
- I access the new address form
- in the address form I select "company"
- the company name input field appears
- I fill in that field
- I continue filling other fields on that form
- now, before saving the new address, I realize that I want to select "individual"
- I select "individual"
- the company name input filed disappears
- I click on the "save" button
The address is saved in the database without anything in the company field.
This scenario fits with everything you've said so far here as far as I understood, and as I said previously, this is already working. I made sure it is by reproducing this scenario on my end.
If this is not working as expected on your end, then there is a bug I'm not able to reproduce on my end with the latest version of HikaShop. That would be something we would need to investigate on your website.
Now, while analyzing what you said and trying to reproduce the issue on my end, I found out that this other scenario could be improved:
- I access the new address form
- in the address form I select "company"
- the company name input field appears
- I fill in that field
- I continue filling other fields on that form
- I save the address
- now, after saving the new address, I realize that I want to select "individual"
- I edit the address
- I select "individual"
- the company name input filed disappears
- I click on the "save" button
In that case, the previously saved company name is still in the database. And I think that ideally, it should not.
Changing this is actually quite easy.
Change the code:
if(isset($formData[$namekey]))
unset($formData[$namekey]);
$skip = true;
to:
$formData[$namekey] = '';
$skip = true;
in the file administrator/components/com_hikashop/classes/field.php via FTP. Then, in this second scenario, the company name is removed from the database during the second save.
I think we're going to add this modification on our end for the next version of HikaShop. If this is what you were talking about, then, do this patch or wait for the next version of HikaShop and you'll get it to work like you want.