[xwiki-users] Wrapping a table in a form
I have a groovy script that takes an array of table data and formats it in a table as follows. As you can see, I'd like to wrap the table in a form. {{groovy}} // [... supplied with array of 2-element arrays...] println "{{html}}" println "<form action=\"\" name=\"chooseForm\" method=post>" println "<input type=hidden name=\"step\" value=\"choose\" /><input type=hidden name=\"form_token\" value=\"${services.csrf.getToken()}\" />" println "{{/html}}" println '|= |= Col 1|= Col2' int lineNo = 0; for (row in rows) { if(lineNo!=0) { // Skip first (header) line print "| {{html}}<input type=checkbox checked=\"checked\" name=\"choose${lineNo}\" form=\"chooseForm\" />{{/html}}" print "| {{html}}<input type=text name=\"col1_${lineNo}\" form=\"chooseForm\" value=\"${row[0]}\"/>{{/html}}" print "| {{html}}<input type=text name=\" col2_${lineNo}\" form=\"chooseForm\" value=\"${row[1]}\" />{{/html}}" print '\n' } ++lineNo; } print "| {{html}}<input type=submit /></form>{{/html}}" {{/groovy}} The problem is that the first {{html}} block closes the form before the table is started. Note that I have tried using ##form="chooseForm"## in the inputs within the table to associate them with the form, but this didn't work, at least with Firefox, since the data for these inputs does not get included in the POST content. Obviously I could use Javascript to modify the form, but I was aiming for a JS-free solution. Any ideas?
Checkout the 'clean' parameter in the HTML macro documentation. Hope this helps, Marius On Dec 12, 2014 6:31 AM, "Bryn Jeffries" <[email protected]> wrote:
I have a groovy script that takes an array of table data and formats it
in a table as follows. As you can see, I'd like to wrap the table in a form.
{{groovy}} // [... supplied with array of 2-element arrays...] println "{{html}}" println "<form action=\"\" name=\"chooseForm\" method=post>" println "<input type=hidden name=\"step\" value=\"choose\" /><input type=hidden name=\"form_token\" value=\"${services.csrf.getToken()}\" />" println "{{/html}}"
println '|= |= Col 1|= Col2' int lineNo = 0; for (row in rows) { if(lineNo!=0) { // Skip first (header) line print "| {{html}}<input type=checkbox checked=\"checked\" name=\"choose${lineNo}\" form=\"chooseForm\" />{{/html}}" print "| {{html}}<input type=text name=\"col1_${lineNo}\" form=\"chooseForm\" value=\"${row[0]}\"/>{{/html}}" print "| {{html}}<input type=text name=\" col2_${lineNo}\" form=\"chooseForm\" value=\"${row[1]}\" />{{/html}}" print '\n' } ++lineNo; }
print "| {{html}}<input type=submit /></form>{{/html}}"
{{/groovy}}
The problem is that the first {{html}} block closes the form before the table is started. Note that I have tried using ##form="chooseForm"## in the inputs within the table to associate them with the form, but this didn't work, at least with Firefox, since the data for these inputs does not get included in the POST content. Obviously I could use Javascript to modify the form, but I was aiming for a JS-free solution. Any ideas? _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Bryn Jeffries -
Marius Dumitru Florea