Open germanrandhawa opened 4 months ago
🤖
Hey @germanrandhawa, nice to see you back! How’s everything going?
Based on the information you've provided, it seems like the issue might be related to how Contact Form 7 is processing the form data.
For the city field, make sure that the value of the selected option is being correctly set and passed when the form is submitted. The value of the selected option should be the one that appears in the email, not the attribute name. If the value is not being set correctly, it could result in "undefined" appearing in the email.
As for the country and state fields printing codes instead of full names, this is likely due to how the data is structured in the countries-states-cities-database
repository. The country and state data is stored using their respective codes, not their full names.
To print the full names instead of the codes, you would need to map the codes to their corresponding names. This could be done by creating a lookup table or dictionary that maps each code to its full name, and then using this to replace the codes with their full names in the email.
Here's a simple example of how you could create such a lookup table for countries:
$countriesJson = file_get_contents("data/countries.json");
$countriesArray = json_decode($countriesJson, true);
$countryCodeToName = array();
foreach($countriesArray as $country) :
$countryCodeToName[$country['code']] = $country['name'];
endforeach;
You could do something similar for states, but you would need to read the state data from the appropriate JSON file based on the country code.
Please note that this is a general guidance and the actual implementation might vary based on your specific setup and requirements.
As for the image you've shared, I'm sorry but I'm unable to view images. If you need to share code or error messages, please paste them as text.
Let me know if you need further clarification or assistance.
Hi,
I am using contact form 7 and added the name attribute on select as below.
Here is my Message body code: City: [city]