Populate listBox from api call

By: Alex Stereochoc | Asked: 04/13/2023
ForumsCategory: Code HelpPopulate listBox from api call
Alex StereochocAlex Stereochoc asked 2 years ago

Hello i would like to populate different list box of my form with data from API.

For example i have a listBox Country and my API send this, i would like this data populate all country in the listbox

 

  [{"id":75,"text":"France","textEN":"France"},{"id":3,"text":"Afghanistan","textEN":"Afghanistan"},{"id":247,"text":"Afrique du Sud","textEN":"South Africa"},{"id":6,"text":"Albanie","textEN":"Albania"},{"id":62,"text":"Alg\u00e9rie","textEN":"Algeria"},{"id":57,"text":"Allemagne","textEN":"Germany"},{"id":1,"text":"Andorre","textEN":"Andorra"},{"id":8,"text":"Angola","textEN":"Angola"},{"id":5,"text":"Anguilla","textEN":"Anguilla"},{"id":9,"text":"Antarctique","textEN":"Antarctica"},{"id":4,"text":"Antigua-et-Barbuda","textEN":"Antigua and Barbuda"},{"id":193,"text":"Arabie saoudite","textEN":"Saudi Arabia"},{"id":10,"text":"Argentine","textEN":"Argentina"},{"id":7,"text":"Arm\u00e9nie","textEN":"Armenia"},{"id":14,"text":"Aruba","textEN":"Aruba"},{"id":13,"text":"Australie","textEN":"Australia"},{"id":12,"text":"Autriche","textEN":"Austria"},{"id":16,"text":"Azerba\u00efdjan","textEN":"Azerbaijan"},{"id":32,"text":"Bahamas","textEN":"Bahamas"},{"id":23,"text":"Bahre\u00efn","textEN":"Bahrain"},{"id":19,"text":"Bangladesh","textEN":"Bangladesh"},{"id":18,"text":"Barbade","textEN":"Barbados"},{"id":36,"text":"B\u00e9larus","textEN":"Belarus"},{"id":20,"text":"Belgique","textEN":"Belgium"},{"id":37,"text":"Belize","textEN":"Belize"},{"id":25,"text":"B\u00e9nin","textEN":"Benin"},{"id":27,"text":"Bermudes","textEN":"Bermuda"},{"id":33,"text":"Bhoutan","textEN":"Bhutan"},{"id":29,"text":"Bolivie","textEN":"Bolivia"},{"id":17,"text":"Bosnie-Herz\u00e9govine","textEN":"Bosnia and Herzegovina"},{"id":35,"text":"Botswana","textEN":"Botswana"},{"id":31,"text":"Br\u00e9sil","textEN":"Brazil"},{"id":28,"text":"Brunei Darussalam","textEN":"Brunei Darussalam"},{"id":22,"text":"Bulgarie","textEN":"Bulgaria"},{"id":21,"text":"Burkina Faso","textEN":"Burkina Faso"},{"id":24,"text":"Burundi","textEN":"Burundi"},{"id":117,"text":"Cambodge","textEN":"Cambodia"},{"id":47,"text":"Cameroun","textEN":"Cameroon"},{"id":38,"text":"Canada","textEN":"Canada"},{"id":52,"text":"Cap-Vert","textEN":"Cape Verde"},{"id":46,"text":"Chili","textEN":"Chile"},{"id":48,"text":"Chine","textEN":"China"},{"id":55,"text":"Chypre","textEN":"Cyprus"},{"id":49,"text":"Colombie","textEN":"Colombia"},{"id":119,"text":"Comores","textEN":"Comoros"},{"id":42,"text":"Congo","textEN":"Congo"},{"id":40,"text":"Congo, R\u00e9publique d\u00e9mocratique du","textEN":"Congo, Democratic Republic of"},{"id":121,"text":"Cor\u00e9e du Nord","textEN":"North Korea"},{"id":122,"text":"Cor\u00e9e du Sud","textEN":"South Korea"},{"id":50,"text":"Costa Rica","textEN":"Costa Rica"},{"id":44,"text":"C\u00f4te d'Ivoire","textEN":"C\u00f4te d'Ivoire"},{"id":98,"text":"Croatie","textEN":"Croatia"},{"id":51,"text":"Cuba","textEN":"Cuba"},{"id":53,"text":"Cura\u00e7ao","textEN":"Cura\u00e7ao"},{"id":59,"text":"Danemark","textEN":"Denmark"},{"id":58,"text":"Djibouti","textEN":"Djibouti"},{"id":60,"text":"Dominique","textEN":"Dominica"},{"id":65,"text":"\u00c9gypte","textEN":"Egypt"},{"id":210,"text":"El Salvador","textEN":"El Salvador"},{"id":2,"text":"\u00c9mirats arabes unis","textEN":"United Arab Emirates"},{"id":63,"text":"\u00c9quateur","textEN":"Ecuador"},{"id":67,"text":"\u00c9rythr\u00e9e","textEN":"Eritrea"},{"id":68,"text":"Espagne","textEN":"Spain"},{"id":64,"text":"Estonie","textEN":"Estonia"},{"id":233,"text":"\u00c9tats-Unis","textEN":"United States"},{"id":69,"text":"\u00c9thiopie","textEN":"Ethiopia"},{"id":71,"text":"Fidji","textEN":"Fiji"},{"id":70,"text":"Finlande","textEN":"Finland"},{"id":76,"text":"Gabon","textEN":"Gabon"},{"id":85,"text":"Gambie","textEN":"Gambia"},{"id":79,"text":"G\u00e9orgie","textEN":"Georgia"},{"id":90,"text":"G\u00e9orgie du Sud et les \u00eeles Sandwich du Sud","textEN":"South Georgia and the South Sandwich Islands"},{"id":82,"text":"Ghana","textEN":"Ghana"},{"id":83,"text":"Gibraltar","textEN":"Gibraltar"},{"id":89,"text":"Gr\u00e8ce","textEN":"Greece"},{"id":78,"text":"Grenade","textEN":"Grenada"},{"id":84,"text":"Groenland","textEN":"Greenland"},{"id":87,"text":"Guadeloupe","textEN":"Guadeloupe"},{"id":92,"text":"Guam","textEN":"Guam"},{"id":91,"text":"Guatemala","textEN":"Guatemala"},{"id":81,"text":"Guernesey","textEN":"Guernsey"},{"id":86,"text":"Guin\u00e9e","textEN":"Guinea"},{"id":88,"text":"Guin\u00e9e \u00e9quatoriale","textEN":"Equatorial Guinea"},{"id":93,"text":"Guin\u00e9e-Bissau","textEN":"Guinea-Bissau"},{"id":94,"text":"Guyana","textEN":"Guyana"},{"id":80,"text":"Guyane fran\u00e7aise","textEN":"French Guiana"},{"id":99,"text":"Ha\u00efti","textEN":"Haiti"},{"id":97,"text":"Honduras","textEN":"Honduras"},{"id":95,"text":"Hong Kong","textEN":"Hong Kong"},{"id":100,"text":"Hongrie","textEN":"Hungary"},{"id":34,"text":"\u00cele Bouvet","textEN":"Bouvet Island"},{"id":54,"text":"\u00cele Christmas","textEN":"Christmas Island"},{"id":104,"text":"\u00cele de Man","textEN":"Isle of Man"},{"id":163,"text":"\u00cele Norfolk","textEN":"Norfolk Island"},{"id":124,"text":"\u00celes Ca\u00efmans","textEN":"Cayman Islands"},{"id":39,"text":"\u00celes Cocos (Keeling)","textEN":"Cocos (Keeling) Islands"},{"id":45,"text":"\u00celes Cook","textEN":"Cook Islands"},{"id":15,"text":"\u00celes d'\u00c5land","textEN":"\u00c5land Islands"},{"id":74,"text":"\u00celes F\u00e9ro\u00e9","textEN":"Faroe Islands"},{"id":96,"text":"\u00celes Heard et McDonald","textEN":"Heard and McDonald Islands"},{"id":72,"text":"\u00celes Malouines","textEN":"Falkland Islands"},{"id":143,"text":"\u00celes Marshall","textEN":"Marshall Islands"},{"id":232,"text":"\u00celes mineures \u00e9loign\u00e9es des \u00c9tats-Unis","textEN":"United States Minor Outlying Islands"},{"id":194,"text":"\u00celes Salomon","textEN":"Solomon Islands"},{"id":214,"text":"\u00celes Turks et Caicos","textEN":"Turks and Caicos Islands"},{"id":240,"text":"\u00celes Vierges am\u00e9ricaines","textEN":"Virgin Islands (U.S.)"},{"id":239,"text":"\u00celes Vierges britanniques","textEN":"Virgin Islands (British)"},{"id":243,"text":"\u00celes Wallis-et-Futuna","textEN":"Wallis and Futuna Islands"},{"id":105,"text":"Inde","textEN":"India"},{"id":101,"text":"Indon\u00e9sie","textEN":"Indonesia"},{"id":107,"text":"Irak","textEN":"Iraq"},{"id":108,"text":"Iran","textEN":"Iran"},{"id":102,"text":"Irlande","textEN":"Ireland"},{"id":109,"text":"Islande","textEN":"Iceland"},{"id":103,"text":"Isra\u00ebl","textEN":"Israel"},{"id":110,"text":"Italie","textEN":"Italy"},{"id":112,"text":"Jama\u00efque","textEN":"Jamaica"},{"id":114,"text":"Japon","textEN":"Japan"},{"id":111,"text":"Jersey","textEN":"Jersey"},{"id":113,"text":"Jordanie","textEN":"Jordan"},{"id":125,"text":"Kazakhstan","textEN":"Kazakhstan"},{"id":115,"text":"Kenya","textEN":"Kenya"},{"id":116,"text":"Kirghizistan","textEN":"Kyrgyzstan"},{"id":118,"text":"Kiribati","textEN":"Kiribati"},{"id":123,"text":"Kowe\u00eft","textEN":"Kuwait"},{"id":126,"text":"Laos","textEN":"Lao People's Democratic Republic"},{"id":132,"text":"Lesotho","textEN":"Lesotho"},{"id":135,"text":"Lettonie","textEN":"Latvia"},{"id":127,"text":"Liban","textEN":"Lebanon"},{"id":131,"text":"Lib\u00e9ria","textEN":"Liberia"},{"id":136,"text":"Libye","textEN":"Libya"},{"id":129,"text":"Liechtenstein","textEN":"Liechtenstein"},{"id":133,"text":"Lituanie","textEN":"Lithuania"},{"id":134,"text":"Luxembourg","textEN":"Luxembourg"},{"id":148,"text":"Macao","textEN":"Macau"},{"id":144,"text":"Mac\u00e9doine","textEN":"Macedonia"},{"id":142,"text":"Madagascar","textEN":"Madagascar"},{"id":158,"text":"Malaisie","textEN":"Malaysia"},{"id":156,"text":"Malawi","textEN":"Malawi"},{"id":155,"text":"Maldives","textEN":"Maldives"},{"id":145,"text":"Mali","textEN":"Mali"},{"id":153,"text":"Malte","textEN":"Malta"},{"id":149,"text":"Mariannes du Nord","textEN":"Northern Mariana Islands"},{"id":137,"text":"Maroc","textEN":"Morocco"},{"id":150,"text":"Martinique","textEN":"Martinique"},{"id":154,"text":"Maurice","textEN":"Mauritius"},{"id":151,"text":"Mauritanie","textEN":"Mauritania"},{"id":246,"text":"Mayotte","textEN":"Mayotte"},{"id":157,"text":"Mexique","textEN":"Mexico"},{"id":73,"text":"Micron\u00e9sie, \u00c9tats f\u00e9d\u00e9r\u00e9s de","textEN":"Micronesia, Federated States of"},{"id":139,"text":"Moldavie","textEN":"Moldova"},{"id":138,"text":"Monaco","textEN":"Monaco"},{"id":147,"text":"Mongolie","textEN":"Mongolia"},{"id":140,"text":"Mont\u00e9n\u00e9gro","textEN":"Montenegro"},{"id":152,"text":"Montserrat","textEN":"Montserrat"},{"id":159,"text":"Mozambique","textEN":"Mozambique"},{"id":146,"text":"Myanmar","textEN":"Myanmar"},{"id":160,"text":"Namibie","textEN":"Namibia"},{"id":169,"text":"Nauru","textEN":"Nauru"},{"id":168,"text":"N\u00e9pal","textEN":"Nepal"},{"id":165,"text":"Nicaragua","textEN":"Nicaragua"},{"id":162,"text":"Niger","textEN":"Niger"},{"id":164,"text":"Nigeria","textEN":"Nigeria"},{"id":170,"text":"Niue","textEN":"Niue"},{"id":167,"text":"Norv\u00e8ge","textEN":"Norway"},{"id":161,"text":"Nouvelle-Cal\u00e9donie","textEN":"New Caledonia"},{"id":171,"text":"Nouvelle-Z\u00e9lande","textEN":"New Zealand"},{"id":172,"text":"Oman","textEN":"Oman"},{"id":231,"text":"Ouganda","textEN":"Uganda"},{"id":235,"text":"Ouzb\u00e9kistan","textEN":"Uzbekistan"},{"id":178,"text":"Pakistan","textEN":"Pakistan"},{"id":185,"text":"Palau","textEN":"Palau"},{"id":183,"text":"Palestine","textEN":"Palestine, State of"},{"id":173,"text":"Panama","textEN":"Panama"},{"id":176,"text":"Papouasie-Nouvelle-Guin\u00e9e","textEN":"Papua New Guinea"},{"id":186,"text":"Paraguay","textEN":"Paraguay"},{"id":166,"text":"Pays-Bas","textEN":"The Netherlands"},{"id":30,"text":"Pays-Bas carib\u00e9ens","textEN":"Caribbean Netherlands "},{"id":174,"text":"P\u00e9rou","textEN":"Peru"},{"id":177,"text":"Philippines","textEN":"Philippines"},{"id":181,"text":"Pitcairn","textEN":"Pitcairn"},{"id":179,"text":"Pologne","textEN":"Poland"},{"id":175,"text":"Polyn\u00e9sie fran\u00e7aise","textEN":"French Polynesia"},{"id":184,"text":"Portugal","textEN":"Portugal"},{"id":182,"text":"Puerto Rico","textEN":"Puerto Rico"},{"id":187,"text":"Qatar","textEN":"Qatar"},{"id":41,"text":"R\u00e9publique centrafricaine","textEN":"Central African Republic"},{"id":61,"text":"R\u00e9publique dominicaine","textEN":"Dominican Republic"},{"id":56,"text":"R\u00e9publique tch\u00e8que","textEN":"Czech Republic"},{"id":188,"text":"R\u00e9union","textEN":"R\u00e9union"},{"id":189,"text":"Roumanie","textEN":"Romania"},{"id":77,"text":"Royaume-Uni","textEN":"United Kingdom"},{"id":191,"text":"Russie","textEN":"Russian Federation"},{"id":192,"text":"Rwanda","textEN":"Rwanda"},{"id":66,"text":"Sahara Occidental","textEN":"Western Sahara"},{"id":26,"text":"Saint-Barth\u00e9lemy","textEN":"Saint Barth\u00e9lemy"},{"id":120,"text":"Saint-Kitts-et-Nevis","textEN":"Saint Kitts and Nevis"},{"id":204,"text":"Saint-Marin","textEN":"San Marino"},{"id":141,"text":"Saint-Martin (France)","textEN":"Saint-Martin (France)"},{"id":211,"text":"Saint-Martin (Pays-Bas)","textEN":"Sint Maarten (Dutch part)"},{"id":180,"text":"Saint-Pierre-et-Miquelon","textEN":"St. Pierre and Miquelon"},{"id":237,"text":"Saint-Vincent-et-les-Grenadines","textEN":"Saint Vincent and the Grenadines"},{"id":199,"text":"Sainte-H\u00e9l\u00e8ne","textEN":"Saint Helena"},{"id":128,"text":"Sainte-Lucie","textEN":"Saint Lucia"},{"id":244,"text":"Samoa","textEN":"Samoa"},{"id":11,"text":"Samoa am\u00e9ricaine","textEN":"American Samoa"},{"id":209,"text":"Sao Tom\u00e9-et-Principe","textEN":"Sao Tome and Principe"},{"id":205,"text":"S\u00e9n\u00e9gal","textEN":"Senegal"},{"id":190,"text":"Serbie","textEN":"Serbia"},{"id":195,"text":"Seychelles","textEN":"Seychelles"},{"id":203,"text":"Sierra Leone","textEN":"Sierra Leone"},{"id":198,"text":"Singapour","textEN":"Singapore"},{"id":202,"text":"Slovaquie","textEN":"Slovakia"},{"id":200,"text":"Slov\u00e9nie","textEN":"Slovenia"},{"id":206,"text":"Somalie","textEN":"Somalia"},{"id":196,"text":"Soudan","textEN":"Sudan"},{"id":208,"text":"Soudan du Sud","textEN":"South Sudan"},{"id":130,"text":"Sri Lanka","textEN":"Sri Lanka"},{"id":197,"text":"Su\u00e8de","textEN":"Sweden"},{"id":43,"text":"Suisse","textEN":"Switzerland"},{"id":207,"text":"Suriname","textEN":"Suriname"},{"id":201,"text":"Svalbard et \u00eele de Jan Mayen","textEN":"Svalbard and Jan Mayen Islands"},{"id":213,"text":"Swaziland","textEN":"Swaziland"},{"id":212,"text":"Syrie","textEN":"Syria"},{"id":219,"text":"Tadjikistan","textEN":"Tajikistan"},{"id":228,"text":"Ta\u00efwan","textEN":"Taiwan"},{"id":229,"text":"Tanzanie","textEN":"Tanzania"},{"id":215,"text":"Tchad","textEN":"Chad"},{"id":216,"text":"Terres australes fran\u00e7aises","textEN":"French Southern Territories"},{"id":106,"text":"Territoire britannique de l'oc\u00e9an Indien","textEN":"British Indian Ocean Territory"},{"id":218,"text":"Tha\u00eflande","textEN":"Thailand"},{"id":221,"text":"Timor-Leste","textEN":"Timor-Leste"},{"id":217,"text":"Togo","textEN":"Togo"},{"id":220,"text":"Tokelau","textEN":"Tokelau"},{"id":224,"text":"Tonga","textEN":"Tonga"},{"id":226,"text":"Trinit\u00e9-et-Tobago","textEN":"Trinidad and Tobago"},{"id":223,"text":"Tunisie","textEN":"Tunisia"},{"id":222,"text":"Turkm\u00e9nistan","textEN":"Turkmenistan"},{"id":225,"text":"Turquie","textEN":"Turkey"},{"id":227,"text":"Tuvalu","textEN":"Tuvalu"},{"id":230,"text":"Ukraine","textEN":"Ukraine"},{"id":234,"text":"Uruguay","textEN":"Uruguay"},{"id":242,"text":"Vanuatu","textEN":"Vanuatu"},{"id":236,"text":"Vatican","textEN":"Vatican"},{"id":238,"text":"Venezuela","textEN":"Venezuela"},{"id":241,"text":"Vietnam","textEN":"Vietnam"},{"id":245,"text":"Y\u00e9men","textEN":"Yemen"},{"id":248,"text":"Zambie","textEN":"Zambia"},{"id":249,"text":"Zimbabwe","textEN":"Zimbabwe"}]

Question Tags:
1 Answers
Victor Font answered 2 years ago
Why are you using an API to retrieve countries instead of the country list built into Formidable?
Alex StereochocAlex Stereochoc replied 2 years ago

this is just a sample. I have a lot of other things to get from my API. I would start with a little sample to understand how to do that.

Victor Font replied 2 years ago

You would have to loop through this code and insert each record into a lookup form. Then you would use the lookup form content in your dynamic field.

Alex StereochocAlex Stereochoc replied 2 years ago

but i have to create an extension ? i have to create a php file ? where to put my php code who get data and send it to formidable form ?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right