# Visual Conditions¶

You can associate conditions to your visual objects so you control rendering and other visual behavior. When those conditions match or not, then your visual objects gain the property you associate with the condition.

Conditions are mapped in the view element id_view as attribute data-xp-cond-rules:

<div    id="id_view"
data-xp="{viewName: 'signup'}"
hasNetAuth: 'settings.SIGNUP_SOCIAL_NETWORK == true',
hasNotNetAuth: 'settings.SIGNUP_SOCIAL_NETWORK == false',
showCaptcha: '  (   isSocialLogged == false &&
form_signup.invitationCode.value == \'\' &&
settings.SITE_SIGNUP_INVITATION == true     ) ||
(   isSocialLogged == false &&
settings.SITE_SIGNUP_INVITATION == false     )',
requiresInvitation: 'settings.SITE_SIGNUP_INVITATION == true'
}" >
</div>


In this case we compare to settings and isSocialLogged. These variables would relate to the visual context. In case you want to compare with a form field, you would do: form_myform.myfiel. You may at your server-side write variables to the visual context with self._add_attr('isSocialLogged', False) from service view.

You can compare:

• ==
• !=
• >
• <
• >=
• <=

## Logical Operators¶

• OR : ||
• AND : &&

You can include parenthesis ( and ) to provide right logic.

## Visual Objects Conditions¶

After you define your view conditions, it is time to map those conditions to your objects.

Our current release forces you to include container visual object, where you place condition logic. In future releases, we will have condition support in all objects.

<div id="id_socialAuth" style="margin-top: 5px;"
data-xp-type="container"
data-xp-cond="{conditions: [
{condition: 'hasNetAuth', action: 'render', value: true}
]}" >
data-xp-type="function.render"
<div class="caption"><span>You can also:</span><br/></div>
data-show-faces="true"
data-width="200"
data-max-rows="1"
</div>
</div>


You can include a set of conditions to match. The first to match, we apply action and skip the rest. The only action currently supported os render, where you can place to true to show or false to hide.