[xwiki-users] Adding objects to pages in inline mode
Hi Guys, I've been using xwiki for a while now, but have only "recently" started using v2 syntax. In v1 a trick I'd often use in apps was to have a nested <FORM> element to allow me to add some pre-filled objects to a page. Something like this: #set ($list = ["Problem", "Feature", "Question"]) <FORM> <SELECT name="field1"> #foreach ($item in $list) <OPTION value="$item">$item</OPTION> #end </SELECT> <INPUT type="submit" name="add" value="add" /> </FORM> Then you could just catch and use the selection: #if ($request.getParameter("add")) $doc.newObject("someclass").set("Field1", $request.getParameter("field1")) $doc.save() Obviously I've taken some shortcuts here. This approach fails to work in inline mode for some reason. My form definition seems to become subsumed by the overall form on the page now. So is there some way for me to declare that I want my form outside of the normal structure? Or is there some smarter way of approaching this problem? Thanks in advance. Cheers, Adam
On 01/28/2011 09:15 PM, [email protected] wrote:
Hi Guys,
Try this: {{html clean="false"}} <fieldset> <input type="hidden" name="classname" value="XWiki.XWikiComments" /> <textarea name="XWiki.XWikiComments_comment" rows="5" cols="80"></textarea> <input type="submit" name="action_objectadd" value="Send comment"/> </fieldset> {{/html}} The trick is the name of the submit button. action_objectadd instructs the server to ignore the action specified in the URL where the form was submitted, and instead to use the action that's specified after the "action_" part, in this case "objectadd". This special form parameter gets submitted only when clicking the "Send comment" button.
I've been using xwiki for a while now, but have only "recently" started using v2 syntax.
In v1 a trick I'd often use in apps was to have a nested<FORM> element to allow me to add some pre-filled objects to a page. Something like this:
#set ($list = ["Problem", "Feature", "Question"]) <FORM> <SELECT name="field1"> #foreach ($item in $list)<OPTION value="$item">$item</OPTION> #end</SELECT> <INPUT type="submit" name="add" value="add" /> </FORM>
Then you could just catch and use the selection:
#if ($request.getParameter("add")) $doc.newObject("someclass").set("Field1", $request.getParameter("field1")) $doc.save()
Obviously I've taken some shortcuts here.
This approach fails to work in inline mode for some reason. My form definition seems to become subsumed by the overall form on the page now.
So is there some way for me to declare that I want my form outside of the normal structure?
Or is there some smarter way of approaching this problem?
Thanks in advance.
Cheers,
Adam
-- Sergiu Dumitriu http://purl.org/net/sergiu/
participants (2)
-
Sergiu Dumitriu -
xwikiadmin@lazypapertiger.org