Custom form – select entity

Hello,

I’m new to the plugin.
I created a custom form to create new contacts.
In this form, I want to display a dropdown list for contacts to choose their nationality.
I get the list of nationalities via a FetchXML query that I display in the select tag.
The nationality field in the crm is linked to an entity, emn_nationalite.
In the contact entity, the nationality field is called “emn_nationalite_id”.
In the entity nationality, the ID is in the field “emn_nationalite_id” and the name of the nationality corresponds to the field “emn_name”.
The contact is created well when I submit the form but the nationality field remains empty in the CRM.
How can I ensure that the nationality is correctly transmitted to the CRM?

Here is my code:

[msdyncrm_twig]
{% form entity="contact" mode="create" required=["lastname", "emailaddress1", "description"] %}
<form method="POST">
<label for="firstname">First Name:</label>
<input name="firstname" required="" placeholder="First Name">
<label for="lastname">Last Name:</label>
<input name="lastname" required="" placeholder="Last Name">
<label for="mobilephone">Phone Number:</label>
<input name="mobilephone" type="tel" placeholder="Phone Number">
<label for="emailaddress2">email:</label>
<input name="emailaddress2" type="tel" placeholder="email">
<label for="nationalite">Nationalité:</label>
<select name="emn_nationalite_id">
 {% for a in nartionality.results.entities %}
        <option value ="{{a.emn_nationaliteid}}">{{a.emn_name}}</option>
      {% endfor %}
</select>

<button type="submit">Submit</button>
</form>
{% endform %}

[/msdyncrm_twig]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer