Class 'Concrete5_Controller_Block_ExternalForm' not found

Permalink
Hi,
I have added an external form into a v8.3.1 website. The form itself renders out as intended and I added the controller file. When I submitted a form, it caused a 404 error. So I cleared the cache and now the form is replaced with an error message "Class 'Concrete5_Controller_Block_ExternalForm' not found".

The form template file is in 'application/blocks/external_form/form/fca_form.php', whilst the controller file is in 'application/blocks/external_form/form/controller/fca_form.php'.

Below is the code from the controller file:
defined( 'C5_EXECUTE' ) or die( 'Access Denied.' );
   namespace Application\Block\ExternalForm\Form\Controller;
   use Concrete\Core\Controller\BlockController;
   use Loader;
   use Core;
   class FCAFormExternalFormBlockController extends BlockController {
      public function action_fca_form( $bID = false ) { ...validation, email code, etc. }
}


And this is the form template file:
<?php
   defined( 'C5_EXECUTE' ) or die( 'Access Denied.' );
   $form = Loader::helper( 'form' );
   if( isset( $response ) ) : echo $response; endif;
?>
   <h4>Request Information</h4>
   <?php if( $response !== 'received' ) : ?>
   <form method="POST" action="<?php echo $view->action( 'fca_form' ); ?>">
...


It just seems to be case of the external form looking for the wrong controller. Any ideas?

Thanks.

 
heckford replied on at Permalink Reply
Well, I got the form to render out but now as I submit the form, it produces a 404 error.
At the moment, the controller is no different to the test form controller so I'm unsure as to what the issue is. I assume that the controller is not being called at all. Filenames match, directory structure checks out. A slightly altered version of the 'test_form' works, just changed the text a little. Not sure which controller gets called, the one in the 'applications' folder or the one in 'concrete' folder. Putting the controller in the 'concrete' folder threw an error, name already in use. Deleted that file, error persists. Deleted the entire 'external_forms' folder, reloaded to clear the error then reuploaded the folder, back to square one - page not found.

<form method="post" action="<?php echo $view->action( 'fca_form' ); ?>">

public function action_fca_form() { ... }


Any help would be gratefully received. Thanks.
heckford replied on at Permalink Reply
Well, this is where I got up to. Still throws a 404 to this location, website.com/submit/1542. The default external 'test' form works fine as it loops back and displays a message.

I got a bit of a steer from here:https://button108.wordpress.com/2016/12/05/external-form-controller-...

application/blocks/external_form/form/custom_contact_form.php
<?php
   $form = Loader::helper( 'form' );
   defined( 'C5_EXECUTE' ) or die( 'Access Denied.' );
   if( isset( $response ) ) : echo $response; endif;
   $time_options = array(
      '' => '----',
      'morning' => 'Morning',
      'afternoon' => 'Afternoon',
      'evening' => 'Evening'
   );
   $hear_options = array(
      '' => '----',
      'google' => 'Google',
      'facebook' => 'Facebook',
      'twitter' => 'Twitter',


application/blocks/external_form/form/controller/custom_contact_form.php
<?php namespace Application\Block\ExternalForm\Form\Controller;
   use Concrete\Core\Controller\AbstractController;
   use Concrete\Core\Page\Controller\PageController;
   use Loader;
   if( !class_exists( 'Application\Block\ExternalForm\Form\Controller\FcaFormContactForm' ) ) :
      class FcaFormContactForm extends AbstractController {
         public function action_submit( $bID = false ) {
            if( $this->bID == $bID ) :
               $form = Loader::helper( 'form' );
               $text = Loader::helper( 'text' );
               $mail = Loader::helper( 'mail' );
               $val = Loader::helper( 'validation/form' );
               $name = $this->post( 'name' );
               $contact_no = $this->post( 'contact_number' );
               $email = $this->post( 'email' );


Thanks.