Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8369843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:45:32+00:00 2026-06-09T13:45:32+00:00

Action create shows form: def create = Action { Ok(html.post.create(postForm)) } How can i

  • 0

Action create shows form:

def create = Action {
    Ok(html.post.create(postForm))
}

How can i modify this action so that for GET request it would give out form and for the POST request it would process user input data, as if it were a separate action:

def newPost = Action { implicit request =>
   postForm.bindFromRequest.fold(
       errors => BadRequest(views.html.index(Posts.all(), errors)),
       label => {
           Posts.create(label)
           Redirect(routes.Application.posts)
       }
   )
}

Wthat i mean is i want to combine this two actions.

UPDATE1: I want a single Action that serves GET and POST requests

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:45:34+00:00Added an answer on June 9, 2026 at 1:45 pm

    I tried once to accomplish similar thing, but I realized that I wasn’t using framework like it was meant to be used. Use separate GET and POST methods like @paradigmatic showed and in cases like you specified "If we take adding comments to another action, we wouldn't be able to get infomation on post and comments in case an error occured (avoding copy-paste code)." – just render the page at the end of controller method with the view you like? and for errors etc. you can always use flash scope too? http://www.playframework.org/documentation/2.0.2/ScalaSessionFlash you could also render this form page with two or more beans and send them to controller side to catch related error messages and data.?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a create action for a form that potentially generates errors (i.e. first
I have a create action in the controller that I use for a form
I have a jQuery post submitting a form to a controller create action, which
If i have a controller action Create that returns a view with the following
I have an action which create QMessageBox. In that dialog I want to print
Okay, I have the following create action #posts_controller, nested resource under discussions def create
I have an ASP.NET MVC 3 application which has a post action called Create
How can I create an action so when a button is clicked the Apple
This is how I post a Micropost as current_user ( Devise ): microposts_controller.rb: def
I am trying to create form that contains another model in rails. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.