External Forms!!

Hi. Going out on a limb here as the developer forum has not been much help. Long and the short of it, I have website running v8.3.1 with an external form. I have followed the developer information but every time I try and submit a form, the website produces a 404 error.

Anyone had this and resolved it?

View Replies:
mnakalay replied on at Permalink Reply
That means the URL you are posting to doesn't exist but without seeing the code we can't really troubleshoot the problem.

Share the code if you want, maybe there's an easy solution.
robran2 replied on at Permalink Reply
Did this get resolved?
I have the same issue, it is likely the controller is not firing because it cannot be found.

The test_form.php does work, but any custom form does not. I have been struggling with this issue for 6 months and getting very little in the way of answers unfortunately.

The form template should be in 'application/blocks/external_form/form'.
The controller according to the docs should be 'application/blocks/external_form/form/controller'.

Both files should have identical filenames. Whatever the action parameter is with in the <form> element, i.e. <?=$view->action('submit')?> should be reflected within the controller file like so public function action_submit( $bID = false ) { ...code... }.

However, having the controller file in the application directory results in a redeclaration of class error regardless of what the class is named, C5 says it exists already. Moving the controller file inside the concrete directory actually works on a local copy of the website. However, this does not work on the live website, it still produces a 404 error.

The directory structure is identical between local and live, only the page ID is different due to each copy of the website using a different database. Swapping out the form block to use the test_form.php template works on both websites.

Controller file
<?php namespace Concrete\Block\ExternalForm\Form\Controller;
   use Concrete\Core\Controller\AbstractController;
   use Concrete\Core\Page\Controller\PageController;
   use Loader;
   use Core;
   class CustomContactForm extends AbstractController {
      public function action_submit( $bID = false ) {
$this->set( 'response', t( 'Thanks!' ) );
         return true;
public function view() {
         $this->set( 'message', t( '' ) );

form template file
   $form = Loader::helper( 'form' );
   defined( 'C5_EXECUTE' ) or die( 'Access Denied.' );
   $cpage = Page::getCurrentPage();
   $currentpage = ( $cpage->getCollectionID() );
<?php if( $message ) : ?><p style="font-weight: bold; font-size: 2em;"><?php echo $message; ?></p><?php endif; ?>
   <?php if( $response !== 'received' ) : ?>
   <form method="post" action="<?=$view->action('submit')?>"> ...fields... 
         <input type="submit" name="submit" value="submit" class="btn btn-primary" />
<?php endif; ?>
robran2 replied on at Permalink Reply
Check your namespace in the controller also. It was originally set to Concrete, I changed it to Application and moved the controller file to 'application/blocks/external_form/form/controller'. This now works correctly across all copies of the website.

namespace Application\Block\ExternalForm\Form\Controller;

I found a similiar issue on the C5 GitHub issues:https://github.com/concrete5/concrete5/issues/2116...

Hope that helps.
afixia replied on at Permalink Reply
One other piece that I found is that the external form cannot be in a stack. The block has to be a page default or added to the page as its own block otherwise you will receive a 404 when submitting.