Bruno Dumon wrote:
Can you describe this in more detail or provide some pseudo code on how a page with multiple forms would be sent and processed (or point to the documentation if there is already something about this)?I'm a bit annoyed by the current status of our flowscript API's for CForms. I'll leave the intro for what it is and just jump right into it:
Form.showForm() =============== I find that this function hides too much of how a form is processed, and stands in the way of doing more advanced stuff.
I propose that instead of Form.showForm(), we just let the user control it:
var form = new Form("my_form_definition.xml"); var finished = false; while (!finished) { cocoon.sendPageAndWait("my-pipeline", {"form": form}); finished = form.processSubmit(); }
In this scenario, you need to write 5 lines instead of one form.showForm() call. However, it provides several advantages:
* You can pass multiple form objects to the sendPageAndWait call (the FTT supports referencing different forms using the location attribute on ft:form-template)
I've had need for this before: having a login form on every page as well as another form. This is my attempt:
With Bruno's code above, you could put a <input type="hidden" name="formID" value="login"/> hidden field into each form that identifies which form was submitted. Then you'd do:
var loginForm = new Form("my_login_form_definition.xml");
var mainForm = new Form("my_main_form_definition.xml");
var finished = false;
while (!finished) {
cocoon.sendPageAndWait("my-pipeline", {"login-form": loginForm, "main-form", mainForm});
if (cocoon.request.formID == "login") {
finished = loginForm.processSubmit();
} else { finished = mainForm.processSubmit();
}
}
That ought to do it. There's a little hack with the cocoon.request.formID, but it should work, as far as I can see.
Regards, Upayavira