Access using language as an initial value in the form

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Access using language as an initial value in the form

fbonin
Hi,
I want to prefill the information of a control by getting the current language that the user is currently using when he is filling the form.

I tried to use xxf:lang() in the initial value field but it does not work :(.

Is there a variable or something that I can use ?
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

Alessandro  Vernet
Administrator
Hi Frederic,

I think you might be hitting this issue:

https://github.com/orbeon/orbeon-forms/issues/1944

Until this is fixed, as a workaround, and as mentioned in that issue, use: xxf:instance('fr-language-instance')/string(). You'll let us know if this did does it for you.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

fbonin
It does not seem to work when I paste the function in the initial value field. Am I doing something wrong ?

Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

fbonin
I was able to make it work using this because I am using Orbeon in a Liferay portlet. :

if(xxf:get-request-header('orbeon-liferay-language') = "fr_CA")
     then 'FR'
     else 'EN'


However, I would like to have the solution if I don't use a portlet.

Thank you !
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

Alessandro  Vernet
Administrator
Hi Frederic,

Are you saying that using `xxf:instance('fr-language-instance')/string()` didn't work for you?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

fbonin
Yes, I added it in the initial value and my text field was not populated.

Did I do something wrong ?
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

Alessandro  Vernet
Administrator
Hi Frederic,

I imagine that the value of that `fr-language-instance` instance is set after the initial values are calculated. It works however if you're using calculated value. Is this something that could work for you?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

fbonin
Hi,
This is just to confirm that it works with calculated value.

Thank you !
Reply | Threaded
Open this post in threaded view
|

Re: Access using language as an initial value in the form

Alessandro  Vernet
Administrator
Frederic, I'm glad using a calculated value works in your case, and thanks for the update.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet