Multiple forms in one page ?

1,037 views
Skip to first unread message

smallufo

unread,
Mar 27, 2010, 3:17:53 PM3/27/10
to play-framework
If my '/register' page has 2 forms :

#{form @App.doRegister()}

#{form @App.doSearch()}

They are both expanded to
<form action="/register" method="POST"...>

But in routes , I can only define 'POST /register' to one
destination :
GET /register App.register
POST /register App.doRegister

How do I route another 'POST /register' to App.doSearch() ?

Ef Rb

unread,
Mar 27, 2010, 4:45:24 PM3/27/10
to play-framework
You can't...so if it's possible I don't really recommend you to do
it (because your project's management will be more complicated).

In fact the routes file has suggestions like:
POST /{Controller}/{Action} {controller}.action

I hope this help.

smallufo

unread,
Mar 27, 2010, 9:45:51 PM3/27/10
to play-framework
Thank you .

But , what if there is two forms in one page ?
It's a normal scenario.
Take this page (groups.google.com) for example , the main canvas is
articles and 'reply' form , and the upper right is 'search' form.
How to accomplish it in Play! ?

Mahmoud Sakr

unread,
Mar 28, 2010, 4:27:57 AM3/28/10
to play-fr...@googlegroups.com
I'm not sure if what you're getting is normal, or whether you're testing it properly or not, but you can always create a form the normal way using standard HTML

<form action="@{App.doSearch()}">

And your other form can be

<form action="@{App.doRegister()}">

and so on.

Guillaume Bort

unread,
Mar 28, 2010, 10:41:18 AM3/28/10
to play-fr...@googlegroups.com
You can have the same path used by 2 different actions. Just use 2
different paths:

POST

> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.
>

Guillaume Bort

unread,
Mar 28, 2010, 10:42:10 AM3/28/10
to play-fr...@googlegroups.com
... Sorry

You can have the same path used by 2 different actions. Just use 2
different paths:

POST /register Application.doRegister
POST /search Application.doSearch

(btw the way search actions are commonly mapped to GET method)

Reply all
Reply to author
Forward
0 new messages