Which HTML tag can be used to accept dynamic class name in Orbeon Forms

 ̄綄美尐妖づ 提交于 2019-12-12 23:13:10

问题


I use Orbeon Forms and I want to set a dynamic class name on a div or span (or any non-XForms tags like xforms:output) so that group of controls can be set with that CSS class.

<div class="color-with-{if(/fetch/data1='Yes') then 'green' else 'red'}">

But this is not working. When I look at the HTML source code after the form is rendered it seems it did not processed that dynamic part.

<div class="color-with-{if(/fetch/data1='Yes') then 'green' else 'red'}"
    id="xf-279">

However this dynamic assignment works pretty good with Orbeon tags.

<xforms:output value="if ((xxforms:valid(instance('account-opening-setup'),true())) 
        and (xxforms:valid(instance('form-variables'),true())))
        then 'Complete' else 'Incomplete'" 
    class="validation-{if ((xxforms:valid(instance('account-opening-setup'),true())) 
        and (xxforms:valid(instance('form-variables'),true()))) then 'complete' 
        else 'incomplete'}" />

Please advise which HTML tag I can use to dynamically assign a class name so that group of controls follow that class CSS.


回答1:


Those expression that use the {...XPath...} syntax are called attribute value templates (AVT), and Orbeon Forms support them in a number of XForms attributes and HTML attributes, including class and style. So your code above should be working.

It might be the case that the AVT is not interpreted because your div isn't in the XHTML namespace. My recommendation is to always use a prefix on your elements. Define the xmlns:xhtml="http://www.w3.org/1999/xhtml" on the root element, and then use xhtml:div instead of div. If you find this too inconvenient, make sure you have the XHTML namespace as your default namespace declared on the root element, with xmlns="http://www.w3.org/1999/xhtml".



来源:https://stackoverflow.com/questions/7415713/which-html-tag-can-be-used-to-accept-dynamic-class-name-in-orbeon-forms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!