Hi,
I have a simple form with a checkbox and a textfield. A click on the checkbox should disable the textfield. Generally, it works fine. But if I use a section template and embed this section template into another form the textfield will not be disabled anymore. It seems that it doesn't recognize the value change. Simple test form: form.xml Global library: global_library.xml Martin |
Administrator
|
Hi Martin, The issue is that you're using instance('fr-form-instance')/test/disabled to access the value of the checkbox. Instead, you should just use $disabled. The former works in the original form, but not when the section is embedded in an XBL component for the section template. Also, instead of just $disabled (or $disabled = true()), I would use $disabled/text() = 'true', which is a bit safer, and will handle the case of the value being empty (thus neither "true" nor "false"). Alex On Fri, May 22, 2015 at 3:58 AM, mabu <[hidden email]> wrote: Maybee related to 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 [hidden email]. To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
thank you, now it works. But I run into another problem. Depending on the value of the attribut disabled I want to execute an action. How can I achieve this? I tried different variations but nothing worked for me. <xf:action if="..." > Martin |
Administrator
|
Hi Martin,
Wow - this is a rather old thread; somehow I missed your message; I'm sorry about that! <xf:action if="..." > in an action should work. In fact, it is used in Orbeon Forms; code all over the place: https://github.com/orbeon/orbeon-forms/search?utf8=%E2%9C%93&q=%22action+if%22&type=Code So something else must be going on here. Would you have some code that shows the problem you're seeing and that you can share with us? Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
i think the problem is the section template. How can I access the disabled value in the action of the section template? <xf:action ev:event="DOMActivate" if="$disabled/text() = true()"> doesn't work for me. <xf:action ev:event="DOMActivate" if="instance()/test/disabled/text() = true()"> works when testing the section template "alone", but it doesn't work if the section template is used in a form. This is the updated global_library.xml Martin |
Administrator
|
In reply to this post by Alessandro Vernet
By the way, in general it is better practice to write:
$disabled/string() = 'true' rather than: $disabled/text() = 'true' the `string()` function takes the string value of the node and is guaranteed to return an XPath string. While `text()` might, depending on the XML data model, return zero, one, or more text nodes. -Erik |
Administrator
|
In reply to this post by mabu
Hi Martin,
Indeed, you can't use $disabled to refer to the value of the disabled field in a section template from outside of the section template, as you might have multiple instances of that section template in your form, or even a field named "disabled" independently of the section templates, and you couldn't know for sure what $disabled is referring to. So you need to use an expression like instance()/test/disabled/string(), assuming the name you gave to the section template in your form is "test". I tried this with your global library, and the following expression works fine, at least in a calculated value: instance()/my-section/disabled (in this case I named the section "my-section"). I hope this helps, Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Alex, thank's for clarifying.
But instance()/test/disabled/string() doesn't work for me even if I give the section template the name test in my simple form posted above!? What do you mean with "at least in a calculated value"? Martin |
Administrator
|
Hi Martin,
I tried this XPath expression in a "Calculated Value" in the "Control Settings" of a field, in Form Builder. Maybe, depending on where your <xf:action> is, instance() might not be referring to the instance you want to. You could try being more explicit, and instead if instance(), use xxf:instance('fr-form-instance'). You'll let us know if this helps, Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
your suggestion doesn't work for me. Can you please have a look at my simple example global_library.xml and form.xml. Martin |
Administrator
|
Hi Martin,
I misunderstood what you were trying to do, and thought you were trying to access the value of a control inside the section template from code outside of the section template. Instead, your trigger is inside the section template, so it is simpler, and the following will show whether the checkbox is checked: <xf:trigger> <xf:label ref="$form-resources/test/label"/> <xf:message event="DOMActivate" value="concat('Disabled: ', instance('fr-form-instance')/disabled)"/> </xf:trigger> Note that instance() returns the root element of the document (not the document node, as doc() does), so the expression is instance(...)/disabled, not instance(...)/test/disabled. Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Thank you Alex. Your suggestion works, if I use the section template in a form. It doesn't work if I want to test the section template inside the form builder.
Martin |
Administrator
|
Hi Martin,
Are you saying that you can't test the trigger inside Form Builder itself? That is to be expected, as for regular triggers clicking on the trigger allows you to edit the label of the trigger. Or are you saying something different? Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
In the bottom bar of the Form Builder there is a test button (http://doc.orbeon.com/form-builder/form-editor.html). I use this button to test the section template before I publish it. In this test case your solution doesn't work. Martin |
Administrator
|
Hi Martin,
Strange, I tried to reproduce this, but it does work fine for me in Form Builder's "Test" dialog: http://i.imgur.com/4tQQjWS.png And here is the source of the library and form: https://gist.github.com/avernet/3f3aad819acc4eeb718a Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Hi Alex,
Testing the form a-a.xml with Form Builder's "Test" dialog works fine. My use case is that I want to test the library a-library.xml (before I publish it) with Form Builder's "Test" dialog. This works not as expected. The value of the input field disabled is not shown in the dialog. Martin |
Administrator
|
Hi Martin, Yes, because when you run it as a form, the expression would need to be instance('fr-form-instance')/section-1/disabled (with the added section-1, or whatever the section name is in your case). If you want the expression to work in both cases, I'd recommend you use xxf:value('disabled-control'). Alex On Mon, Jan 25, 2016 at 10:54 PM mabu <[hidden email]> wrote: Hi Alex, 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 [hidden email]. To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Administrator
|
And for the documentation on xxf:value(), see: Alex On Fri, Jan 29, 2016 at 3:28 PM Alessandro Vernet <[hidden email]> wrote:
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 [hidden email]. To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Alex, thank you! Now it works in both cases.
|
Free forum by Nabble | Edit this page |