Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Won't Do
-
WW 2.2.1
-
None
-
None
Description
It would be nice for input fields to be able to, if an attribute such as indexed="true" is set to depend on an iterator. So for example:
<ww:iterator value="fruits">
<ww:text name="name" indexed="true"/><br>
<ww:text name="color" indexed="true"/><br>
</ww:iterator>
would generate if KeyProperty were specified (in this example as the name property):
<input type="text" name="fruits('orange').name" value="orange">
<input type="text" name="fruits('orange').color" value="orange">
<input type="text" name="fruits('apple').name" value="apple">
<input type="text" name="fruits('apple').color" value="red">
<input type="text" name="fruits('banana').name" value="banana">
<input type="text" name="fruits('banana'').color" value="yellow">
etc.
Or in the case of a List where KeyProperty is not specified:
<input type="text" name="fruits[0].name" value="orange">
<input type="text" name="fruits[0].color" value="orange">
<input type="text" name="fruits[1].name" value="apple">
<input type="text" name="fruits[1].color" value="red">
<input type="text" name="fruits[2].name" value="banana">
<input type="text" name="fruits[2].color" value="yellow">
etc.
Something also that might be helpful is to be able to add a prefix to the name, if fruits, say were a subproperty of the submitting action, so in the first example:
<ww:iterator value="fruits">
<ww:text name="name" indexed="true" prefix="fruitbowl."/><br>
<ww:text name="color" indexed="true" prefix="fruitbowl."/><br>
</ww:iterator>
Would generate:
<input type="text" name="fruitbowl.fruits('orange').name" value="orange">
<input type="text" name="fruitbowl.fruits('orange').color" value="orange">
<input type="text" name="fruitbowl.fruits('apple').name" value="apple">
<input type="text" name="fruitbowl.fruits('apple').color" value="red">
<input type="text" name="fruitbowl.fruits('banana').name" value="banana">
<input type="text" name="fruitbowl.fruits('banana'').color" value="yellow">
Now comes the hard question. What would be the ideal way to deal with nested iterators? The way I have thought of is to use another attribute called nested, which if set to true would index all previous loops. So, if we have:
<ww:iterator value="fruitbowls">
<ww:iterator value="fruits">
<ww:text name="name" indexed="true" prefix="fruitbowl."/><br>
<ww:text name="color" indexed="true" prefix="fruitbowl."/><br>
</ww:iterator>
</ww:iterator>
It would generate:
<input type="text" name="fruitbowls[0].fruits('orange').name" value="orange">
<input type="text" name="fruitbowls[0].fruits('orange').color" value="orange">
<input type="text" name="fruitbowls[0].fruits('apple').name" value="apple">
<input type="text" name="fruitbowls[0].fruits('apple').color" value="red">
<input type="text" name="fruitbowls[0].fruits('banana').name" value="banana">
<input type="text" name="fruitbowls[0].fruits('banana'').color" value="yellow">
<input type="text" name="fruitbowls[1].fruits('orange').name" value="orange">
<input type="text" name="fruitbowls[1.fruits('orange').color" value="orange">
<input type="text" name="fruitbowls[1].fruits('apple').name" value="apple">
<input type="text" name="fruitbowls[1].fruits('apple').color" value="red">
<input type="text" name="fruitbowls[1].fruits('banana').name" value="banana">
<input type="text" name="fruitbowls[1].fruits('banana').color" value="yellow">
Comments?