How to accès HTML data-attribute with Twig?

623 Views Asked by At

Not sure if this is possible, but I've a link with data-attributes 'data-form-recipient' set by Json objects :

 <a class="callback-form" href="#location-form" id="contact-us-recipient" data-form-recipient="${myCustomLayers.properties.locationRecipient}">

When trying to get the data from this with JS, It looks all good and gives me the email addresses I want ->

var elem = document.getElementById('contact-us-recipient');
            var recipient= elem.getAttribute('data-form-recipient');
            console.log(recipient)

Thing is, I need to access it with Twig because this is for a Freeform dynamicNotification (Craft 3), in this context :

{% set form = craft.freeform.form("contactLocation", {
                                        dynamicNotification: { recipients: [
                                            recipient
                                        ], template: "locationContactTmp" }
                                    }) %}

Where 'recipient' must be my data-form-recipient value. Is this possible and how? Thanks

0

There are 0 best solutions below