Populate dropdowns based on a field in a repeating section not working

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

Populate dropdowns based on a field in a repeating section not working

James Newcombe
I have a dropdown field in a repeating section that is used to select a system name, and based on that a whole bunch of other dropdowns in the form are populated from a database with system-specific choices. It works just fine, as long as no-one actually repeats the initial section.

If the section is repeated, the form behaves as though the system choice has now become dependent on the system name chosen in the second iteration. A third iteration makes the form dependent on the system chosen in the third iteration, and so on.

To add to the excitement, I also have a repeating section where a set of dropdowns in that section are populated with values dependent on the system name chosen from a dropdown in that section. That also works perfectly, until the section is repeated. In the second (and subsequent) iteration, all values from every iteration become dependent on the value in the latest iteration.

The simplest way to explain it may be like this; the XML created by the repeating sections is structured something like :

<section>
   <system/>
   <payment method/>
   <bank/>
</section>
<section>
   <system/>
   <payment method/>
   <bank/>
</section>

So the list of available choices of payment method in block 1 should be dependent on the system selected in block 1, the list of available choices of payment method in block 2 should be dependent on the system selected in block 2, and so on.

What's actually happening is that it works fine when there is only a block 1, but when I create a new repeat of the section, the list of available choices of payment method in blocks 1 and 2 now depends on the system chosen in block 2. If a third block is created, everything in all blocks becomes dependent on the system chosen in block 3.

Sometimes I need the choices to depend on a value in the same repeating section, other times I want choices in different parts of the form to depend on a value in a repeating section.There isn't (at least in Form Builder) a way to choose which iteration of a field you want to base your selections on - for instance using the example above, fields in a stock availability section of the form might be populated based only on a value set in section[1]/system[1], regardless of how many section[] blocks there are.

Have I found a bug, or just failed to find a correct method of coding what I'm trying to do ?

Reply | Threaded
Open this post in threaded view
|

Re: Populate dropdowns based on a field in a repeating section not working

Alessandro  Vernet
Administrator
Hi James,

Let me see if I understand this properly: upon the user changing the value of <system/>, you're calling a service that sets <payment method/>, and you want to set the the <payment method/> in the section corresponding to the <system/> that was changed. Is that correct?

If that is the case, this should work since 4.5, and for reference this is the corresponding issue:


Alex

On Thu, May 28, 2015 at 1:55 PM, James Newcombe <[hidden email]> wrote:
I have a dropdown field in a repeating section that is used to select a
system name, and based on that a whole bunch of other dropdowns in the form
are populated from a database with system-specific choices. It works just
fine, as long as no-one actually repeats the initial section.

If the section is repeated, the form behaves as though the system choice has
now become dependent on the system name chosen in the second iteration. A
third iteration makes the form dependent on the system chosen in the third
iteration, and so on.

To add to the excitement, I also have a repeating section where a set of
dropdowns in that section are populated with values dependent on the system
name chosen from a dropdown in that section. That also works perfectly,
until the section is repeated. In the second (and subsequent) iteration, all
values from every iteration become dependent on the value in the latest
iteration.

The simplest way to explain it may be like this; the XML created by the
repeating sections is structured something like :

<section>
   <system/>
   <payment method/>
   <bank/>
</section>
<section>
   <system/>
   <payment method/>
   <bank/>
</section>

So the list of available choices of payment method in block 1 should be
dependent on the system selected in block 1, the list of available choices
of payment method in block 2 should be dependent on the system selected in
block 2, and so on.

What's actually happening is that it works fine when there is only a block
1, but when I create a new repeat of the section, the list of available
choices of payment method in blocks 1 and 2 now depends on the system chosen
in block 2. If a third block is created, everything in all blocks becomes
dependent on the system chosen in block 3.

Sometimes I need the choices to depend on a value in the same repeating
section, other times I want choices in different parts of the form to depend
on a value in a repeating section.There isn't (at least in Form Builder) a
way to choose which iteration of a field you want to base your selections on
- for instance using the example above, fields in a stock availability
section of the form might be populated based only on a value set in
section[1]/system[1], regardless of how many section[] blocks there are.

Have I found a bug, or just failed to find a correct method of coding what
I'm trying to do ?



--
View this message in context: http://discuss.orbeon.com/Populate-dropdowns-based-on-a-field-in-a-repeating-section-not-working-tp4659997.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
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].

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Populate dropdowns based on a field in a repeating section not working

James Newcombe
Alex,

Thanks for the quick reply. I guess that means it's probably my code. I'll try to find some other ways of solving the problem.

Thanks,
James.
Reply | Threaded
Open this post in threaded view
|

Re: Populate dropdowns based on a field in a repeating section not working

Alessandro  Vernet
Administrator
Hi James,

OK, you'll let us know if you find more about this, and if you can get to what causes the issue, hopefully you can create a simple example that reproduces the problem.

Alex

On Fri, May 29, 2015 at 12:19 AM, James Newcombe <[hidden email]> wrote:
Alex,

Thanks for the quick reply. I guess that means it's probably my code. I'll
try to find some other ways of solving the problem.

Thanks,
James.

--
View this message in context: http://discuss.orbeon.com/Populate-dropdowns-based-on-a-field-in-a-repeating-section-not-working-tp4659997p4660000.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
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].

--
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