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 7824513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:37:21+00:00 2026-06-02T08:37:21+00:00

I’m new to wheels and still learning. It seems to me that every post

  • 0

I’m new to wheels and still learning. It seems to me that every post of a form needs to call an action that maps to a method in the particular model. However, is it possible for a form to post to itself?

What I want to avoid is people navigating to an action view directly – which seems to throw an error. I’d also like to do a lot of self-posting because it might mean I won’t have to have a lot of empty files laying around in my views folder.

Another advantage I was thinking about was the fact that if a form is self posting, I’d have the benefit of having it used globally. For example, I might have a form in my header that I want my user to fill out anywhere in the website. Or is there a way to detect where the user came from and do a dynamic redirectTo?

Many thanks,
Michael.

  • 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-02T08:37:25+00:00Added an answer on June 2, 2026 at 8:37 am

    To avoid errors due to users browsing to post actions, look at Verification:
    http://cfwheels.org/docs/chapter/verification

    So your create and update actions would be configured like this in the controller’s init:

    <cffunction name="init">
        <cfset verifies(only="create,update", post=true, params="comment", paramsTypes="struct")>
    </cffunction>
    

    It is not unreasonable to redirect the user back to the previous page after the form has posted. Look at redirectTo(back=true) for your success action.
    http://cfwheels.org/docs/1-1/function/redirectto

    <cffunction name="init">
        <cfscript>
            verifies(only="create,update", params="comment", paramsTypes="struct");
            provides("html,json");
        </cfscript>
    </cffunction>
    
    <cffunction name="create">
        <cfscript>
            comment = model("comment").new(params.comment);
            comment.save();
    
            if (isAjax())
            {
                renderWith(comment);
            }
            else
            {
                if (comment.hasErrors())
                    redirectTo(back=true, error="There was an error saving the comment.");
                else
                    redirectTo(back=true, success="The comment was posted successfully.");
            }
        </cfscript>
    </cffunction>
    

    Yes, I like Craig’s answer that AJAX is a good solution, but you also need to consider what happens if the AJAX fails and the form is ultimately posted to the URL through a non-AJAX request. Best to provide a fully accessible experience.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

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.