Structured form submission with for loop (Groovy)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Structured form submission with for loop (Groovy)

Jochen-A-Fuerbacher
Hello,
I do have some trouble using structured form submission from within a for loop.
My Groovy file generates a table with one row per list object. I can edit the table (select, textfields, whatever). However the submitted value doesn't look like what I expacted.

The relevant part of the groovy file:

f.form(action: "doSomething", method:"post", name:"submitSomeForm") {
                table
(id:"showSomeFields", border:"1px", class:"pane sortable") {
                    thead
() {
                        tr
(){
                            th
(class:"pane-header") { text("...") }
                           
...
                       
}
                   
}

                    tbody
(){
                       
for(MyObject object : my.getMyObjects()){
                            tr
(){
                                div
(name:object.getName()){
                                    td
(align:"left") {
                                        a
(href:"...", object.getName())
                                        input
(type:"hidden", name:"name", value:object.getName())
                                   
}
                                    td
(align:"left"){
                                       
select(name:"selectedObject"){
                                            f
.option(value: "Option1", _("Option1"))
                                            f
.option(value: "Option2", _("Option2"))
                                            f
.option(value: "Option3", _("Option3"))
                                       
}
                                   
}
                                 
...
                               
}
                           
}
                       
}
                   
}
               
}

                f
.entry(){
                    f
.submit(name:"start", value:_("Start doing something"))
               
}
           
}
}



As described here, I expacted a submitted value of something like
{ first: { name:"first", selectedObject: "Option1" },
  second
: { name:"second", selectedObject: "Option2" },
  third
: { name:"third", selectedObject: "Option1" }
}

however the submitted value looks like this:

{
  name
: ["first", "second", "thrid"],
  selectedValue
: ["Option1", "Option2", "Option1" ]
}



--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fdd1d2cb-9859-4bb2-bf58-2d5b10941d4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.