Link custom module with event detail page

I’m having problems trying to link a custom module on an event detail layout page. I have a custom module of location details which I want to link to the location2 field in the event. I’ve set this up in event settings - just trying to get the layout to work correctly.

I want to use the custom module location details (address, maplink etc) on the event detail list and also populate the form with those fields (for the workflow).

This is my code :
{% component source: “Inspection Stations”, layout: “List”, sortBy: “name”, sortOrder: “ASC”, limit: “100”, object: “collection”, collectionVariable: “location”, type: “module” %}

event location : {{this.location2}}
location locaiton : {{location.id}}

{% for i in location.items %}

{% if i.id=this.location2 %}

{% assign locationid = i.id %}
{% assign locationname = i.name %}
{% assign locationaddress = i.property_address %}
{% assign locationmaplink = i.maplink %}

{% endif %}

{% endfor %}

{{locationid}}
{{locationname}}
{{locationaddress}}
{{locationmaplink}}

The problem is that this code is only picking up the last location item from the custom module. How do I get it to do a match to the current {{this.location2}} field and where do I place the if statement. I’ve tried it in a few places but am often getting a blank page.

Don’t worry - found it. I was just missing the double equals sign
{% if i.id == this.location2 %}