Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Inserting Conditional Text between Floating Fields

Avatar

Level 2

I have two data fields that flow fine to their specific floating fields.  field1 has a name1 and field2 has a name2.  I have them carry down and read using two floating fields to read "(name2)   (name 1) Form"  what i would like to do is to have the word "and" appear between the two floating fields...but only when there is something entered into field2 that contains the second name.  So the final result should 2 names be entered would be "(name2) and (name1) Form".

I have worked on this for a bit and can't seem to get it to work.  Any help would be great.

3 Replies

Avatar

Former Community Member

How about this....

I have a form with two floating fields, 'apples' and 'oranges'.  In between the two fields I add a text field called 'andTxt' (containing the word 'and')  with a presence property of 'hidden'. When I merge the .xml into the template the form:ready event fires with the attached script. If data is bound to 'oranges' then 'andTxt' is made visible. You could perform similar logic through a field event rather than on the form event, if necessary.

// form1.page1::ready:form - (JavaScript, client)

if (!form1.page1.oranges.isNull) {

     form1.page1.andTxt.presence = "visible";

}

Steve

Avatar

Level 2

I have to two floating fields inserted into the same text field.  So when i insert this other text field is there a way to put it between the two floating fields?  Or maybe I am misunderstanding.  Thanks for the response.

Avatar

Level 2

I was able to get it working.  Thanks for the help.