How to add a class to the CountrySelector (K11)

Deb Apprille asked on October 14, 2019 23:53

Hi, I want to add a class to the country selector like this:

<select>
  <option value="5678" class="{%CountryTwoLetterCode%}">Canada</option>
  <option value="1234" class="{%CountryTwoLetterCode%}">USA</option>
  ...more countries...
</select>

But I cannot for the life of me figure out where to do this. It doesn't need to be a class, it could also be a data- tag. I basically need to display the two-letter code somewhere so I can pass it to an address look-up API.

Thank you,

Deb A.

Correct Answer

David te Kloese answered on October 15, 2019 11:55

Do you really need the Country selector? As it's not that flexible. You could for instance use a Drop-down list and use the 'two letter country code':

setting

script:

SELECT NULL AS CountryTwoLetterCode, '(please select)' AS CountryDisplayName 
FROM CMS_Country
UNION
SELECT [CountryTwoLetterCode], [CountryDisplayName] 
FROM [CMS_Country]
ORDER BY CountryDisplayName

Which will have the following HTML output:

output

0 votesVote for this answer Unmark Correct answer

Recent Answers


Deb Apprille answered on October 15, 2019 16:28 (last edited on December 10, 2019 02:31)

Thanks for the reply! We ended up going with your solution. One caveat for others:

We had issues with the logic for the connecting state dropdown because SQL expects single quotes and macros use double quotes.

{% Fields["AddressCountryText"] |(identity)GlobalAdministrator%}

We ended up using SQLEscape for the macro and it works now. Thanks again!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.