Changing section's label dynamically

27 views
Skip to first unread message

fbonin

unread,
Sep 13, 2016, 8:40:54 PM9/13/16
to orb...@googlegroups.com
Hi,
I would like to change the labels of a section dynamically based on what the
user selected in the form (the user is using a wizard view). Is this
possible to do ?

I was thinking of creating a custom xf:action that would update the label as
the section changes.

I was able to change the value of an input using this code :

<xf:action event="xforms-ready">
<xf:setvalue ref="//mycontrol">working</xf:setvalue>
</xf:action>

However, it does not work for sections. I am also unable to change the label
dynamically of an input field. Is this possible to do also ?

Thank you !

--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

Alessandro Vernet

unread,
Sep 14, 2016, 7:59:06 PM9/14/16
to orb...@googlegroups.com
Hi Frederic,

A couple of questions:

- And is this in the context of a form you created with Form Builder? I.e.
you'd like to programmatically change the label of a section, which normally
is just entered in Form Builder itself?
- Is your form available in multiple languages, or do you have just 1
language?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767p4661769.html

fbonin

unread,
Sep 15, 2016, 2:06:30 PM9/15/16
to orb...@googlegroups.com
- And is this in the context of a form you created with Form Builder? I.e.
you'd like to programmatically change the label of a section, which normally
is just entered in Form Builder itself?

Yes, we want to have a generic label and change it only for a certain
scenario in the form

- Is your form available in multiple languages, or do you have just 1
language?

Yes (just 2 languages though and it won't grow)

--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767p4661772.html

Alessandro Vernet

unread,
Sep 15, 2016, 2:26:11 PM9/15/16
to orb...@googlegroups.com
Hi Frederic,

Got it; so, you could, editing the source of the form in Form Builder:

1. Find the <xf:instance> with id="fr-form-resources". In this instance,
remove the xxf:readonly="true", so you can programmatically change the
content of that instance.

2. Set the value with code along these lines (here assuming this is
triggered by a button named `set-label`, and that the control you're setting
the label of is named `my-control`.

<xf:action observer="set-label-control" event="DOMActivate">
<xf:setvalue ref="instance('fr-form-resources')/resource[@xml:lang =
'en']/my-control/label"
value="'My value'"/>
</xf:action>

You'll let us know if this works for you,

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767p4661773.html

fbonin

unread,
Sep 15, 2016, 4:20:00 PM9/15/16
to orb...@googlegroups.com
Great that makes sense to modify the resource directly ! I guess I can do the
same thing for Ouput Control if I want to change the default label based on
a reply from a web service ?

I was trying to modify the label field using xpath instead of accessing the
resource. Would it be possible to do it this way instead (I am just curious
) ?



--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767p4661774.html

Alessandro Vernet

unread,
Sep 15, 2016, 6:33:13 PM9/15/16
to orb...@googlegroups.com
Hi Frederic,

Yes, you can change the label (as well as the hint, help, and alert) for any
control using the same technique.

What do you mean by "modify the label field using xpath instead of accessing
the resource"? In the `xf:setvalue`, you point to what you want to change
using an XPath expression (e.g.
`instance('fr-form-resources')/resource[@xml:lang =
'en']/my-control/label`), and the value you want to set using another XPath
expression, which in the above example was just a string (`'My value'`).

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
View this message in context: http://discuss.orbeon.com/Changing-section-s-label-dynamically-tp4661767p4661775.html

Mani

unread,
Jun 24, 2020, 9:17:13 PM6/24/20
to Orbeon Forms
Hi Alex - I can see that the label in the wizard tree/toc is picked from the top level section labels. Is there a way to keep wizard tree/toc labels unique as supposed to picking the label from top level section labels?

For ex: Top level section label is 'Transport' but I want wizard tree/toc label as 'Travel arrangements'

Cheers

Mani

unread,
Jun 30, 2020, 2:27:52 AM6/30/20
to Orbeon Forms
Hi Alex - Have you had a chance to look into this?

Alessandro Vernet

unread,
Jul 3, 2020, 7:54:35 PM7/3/20
to orb...@googlegroups.com
Hi Manish,

I'm sorry for the delay! But I'm not following: if you'd like you wizard
section to be named "Travel arrangements", why not name your top-level
section in Form Builder "Travel arrangements"?

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

MANISH B

unread,
Jul 3, 2020, 8:28:29 PM7/3/20
to orb...@googlegroups.com
I have a scenario where they need to be different. Can they both be independent of each other?

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1593820474053-0.post%40n4.nabble.com.

Alessandro Vernet

unread,
Jul 6, 2020, 8:03:54 PM7/6/20
to orb...@googlegroups.com
Hi Manish,

Can you share more details about your use case? I am not picturing what you
mean by different top-level sections and top-level wizard sections; in the
wizard mode, the top-level sections are the top-level wizard sections. Maybe
a realistic example of what you're shooting for would help.

Alessandro Vernet

unread,
Jul 13, 2020, 12:48:20 PM7/13/20
to orb...@googlegroups.com
Hi Manish,

Have you found a way to name the wizard section the way you wanted? If not,
could you help me understand what the situation is, per my earlier message?
Reply all
Reply to author
Forward
0 new messages