How can I test whether both the field are not empty in dialog in sightly | Community
Skip to main content
Adobe Employee
July 20, 2021
Solved

How can I test whether both the field are not empty in dialog in sightly

  • July 20, 2021
  • 4 replies
  • 2659 views

Hi all,

 

I'm trying check whether both the fields are present in the dialog using or condition. It is failing how can I use 'or' condition in data-sly-test for fields renditions in single div.

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral}" || data-sly-test="${contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

I tried above statement but its failing. Can anyone help me with this?

 

Thank you

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BimmiSo

Hi @keerthana_h_n ,

 

The syntax is incorrect as if you need to add OR condition sly-test you can write as below.

<div data-sly-test="${condition 1 || condition 2}">

 

Please try as below:

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Hope this helps!!

 

Thanks

 

4 replies

Shubham_borole
Community Advisor
Community Advisor
July 20, 2021

Hi,

Please try 

 

<p data-sly-test="${properties.jcr:title || properties.myTitle}">My Text</p>

 

or

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 However this or condition can be checked in model and passed as a boolean to be checked in the html

arunpatidar
Community Advisor
Community Advisor
July 20, 2021

Hi try

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

Arun Patidar
BimmiSoAdobe EmployeeAccepted solution
Adobe Employee
July 21, 2021

Hi @keerthana_h_n ,

 

The syntax is incorrect as if you need to add OR condition sly-test you can write as below.

<div data-sly-test="${condition 1 || condition 2}">

 

Please try as below:

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Hope this helps!!

 

Thanks

 

VeenaVikraman
Community Advisor
Community Advisor
July 21, 2021

@keerthana_h_n In your query ( i copied it below) you need to remove the characters marked in bold letters 

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral}" || data-sly-test="${contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

AS others mentioned it should be

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Thanks

Veena