Smarty for Multi-select Entities for Notifications

In Motion 2, you can create a form that can use mutli-select values. This documentation is to help understand how you can set your email notification trigger in Motion 2 to include all selected values. Please note that the example below is from a custom Entity, and these entities will depend on what you have set in your installation.


Setting up a loop to print all elements in a multi-entity:


The entity selected is an Array of Objects. In order to access each, there will be some understanding of the data required.



If the variable itself is selected, it will default to the first Element. In order to get all of the elements, you will have to right click the title with the brackets [] and click insert formatted value.



The following expression will be pasted:


{foreach from=$PrimaryRoleAssignee.entities.Vision_Trip_Request_35.VisionTripRequest.0.type_of_guest key=key item=row}
 {* print array items, like {$row.var} *} 
{foreachelse}
 no iteration 
{/foreach}


The {foreachelse} exists if there is a possiblility for the user filling the form leaving the field blank. It will show if the array is empty.


The item correlates to the curly braces (image below), which by themselves will not give any values. 


To access the values below you will need use '.' followed by the name of the variable. In this case, {$row.type_of_guest_you_are_bringing}

 


This print will be completely unformatted if you do not add html around each of the pieces. In this case, it is a list of types of people coming so it makes sense as a bulleted list. Everything inside the {foreach} will be added for every answer the person who filled the field out added (official for each element in the array). In order to format this so it will not just be a list of unspaced tex,t we can add a <ul> tag around the whole expression and a <li> tag around each answer (element):


<ul>
{foreach from=$PrimaryRoleAssignee.entities.Vision_Trip_Request_35.VisionTripRequest.0.type_of_guest key=key item=row}
    <li>{$row.type_of_guest_you_are_bringing}</li>
{/foreach}
</ul>


This will finally give us our desired result.


It should be noted this is the case for every entity in the variable tree that starts with the <[] some name> as they are all multi and will only show the first element unless a similar loop is set up.






Modified on Mon, 25 Mar 2024 at 11:32 AM

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Make sure these features are added to your Site Stacker installation by learning how to run updates here!