By suit4 on
I added a customized country select list to my profile page.
Countries are mostly written like 'Germany' or 'United Kingdom', but there are some, like 'Brazil, Federative Republic of', so it can be found under 'B'.
I have entered all countries into the text field, each on a single row. Drupal splits this data on every row AND on every comma.
I want
Burundi, Republic of
Cambodia, Kingdom of
Cameroon, United Republic of
but I get
Burundi
Republic of
Cambodia
Kingdom of
Cameroon
United Republic of
How can I change this behaviour? Yes, I know, but using some other symbols instead of a comma is the last option.
Thanks
Comments
split fields
the question really is how are you generating or displaying the listed countries? select drop-down? multi-select?
Below is a snippet of what I use, it merely selects the name and numerical id of a country from a list (ISO based, includes comma'd names like you are describing) and orders it according to the country id.
Of note, because the comma is used in SQL queries, be careful how you insert your country names so it doesn't treat it as a field delimiter (although it would typically error out)
Listed countries are displayed as a single select list.
I used the profile.module and added a filed with type 'list selection'. Then I added the data in 'selection options'.
I didn't customize anything there and there is no special view to this page, just a modified profile.
I don't have any idea, where to put your code and build up a profile submission form by hand.
I THink, this is more an issue in the profile.module.
It splits the text field content by newline, by linefeed an by comma.
For now, i removed the comma on the split command.
I'm going to file an issue for the profile.module. I think, splitting by comma AND newline is too much or, at least should be mentioned.
It would be nice to have this configurable.
Thanks, anyway.
Maybe you like to tell me, how to use your code?
How to use the code
the code sample I provided is part of the forms API, in order to use it you would need to build a custom form.
Thanks, but ..
Thanks for the code,
but I'll stick with my way for now.
Actually I got it working with my workaround.
Now I can use those country list entries to send a query to yahoo maps and get a geocode for the country and city (if set) :)
I see this didn't get fixed.
I see this didn't get fixed. I hacked the code the same as you.
Chris