Call to controller method throwing 404 page not found error


I am trying to build a custom package for one of my clients, I have installed the package successfully with a blank controller and view file, but when I attempt to follow Andrew's tutorial located here:

I am able to create the form no problem but when I hit 'search' it says 'page not found'.

I don't really understand why its not finding the controller method?

My file structure is as follows


Contents of pages:


<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
$dh = Loader::helper('concrete/dashboard');
$ih = Loader::helper('concrete/interface');
$uNamePosted = "test value";
$help = 'This add-on works in conjuction with my XML Export add-on ';
$help .= 'this is a new dashboard page which allows you to open these';
$help .= 'XML files, edit and then save them, so that you can then';
$help .= 'import them using Core Commerce Import.';
echo $dh->getDashboardPaneHeaderWrapper(t('XML Viewer'), t($help), 'span8', false);
<div class="ccm-pane-body">
   <form method="post" 
    action="<?php echo $this->action('test_form'); ?>">
    <?php echo $uNamePosted; ?>
    <input type="text" name="uName" value="" />


<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
class XmlViewerController extends Controller {
  public function test_form() {
        $uName = $_POST('uName');
        $this->set('uNamePosted', $uName);


<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
if (!defined('XML_VIEWER_CC_CORE')) define('XML_VIEWER_CC_CORE', true);
class XmlViewerPackage extends Package {
   protected $pkgHandle = 'xml_viewer';
   protected $appVersionRequired = '5.5';
   protected $pkgVersion = '1.0';
   public function getPackageDescription() {
      return t('Open, Edit, and Save XML files for use with the Core Commerce Import Add-on');
   public function getPackageName(){
      return t('XML Viewer');
   public function on_start() {
   public function install() {

I'm at a loss as far as I can tell I have exactly what he has except I have simply changed the names to suit the purposes of my add on and added a basic help description.

For my install script I simply re-purposed some code from the E-Commerce Import Add-on

Can anyone tell me what I am missing here?

View Replies:
CaptainPanda replied on at Permalink Reply
I just was able to find out why the 404 error was happening

My controller did not have the right name

should have been

However now I have another problem, nothing actually happens when the form posts. The default string of 'test value' does not change

I also changed this

$uName = $_POST['uName'];
        $this->set('uNamePosted', $uName);

Back to this
$uName = $this->post('uName');
        $this->set('uNamePosted', $uName);

Neither of which worked. Why is there no up to date tutorials on any of this? Having to stop development for 3-4 days every single week because I have to wait for a response on the forum is getting a little ridiculous....

A little more info I have tried adding

print ("some test text"); to the top of my function in controller.php

It produces this error:

Cannot modify header information - headers already sent by (output started at public_html/site/packages/xml_viewer/controllers/dashboard/core_commerce/xml_viewer/controller.php:6) in <b>public_html/site/concrete/core/libraries/view.php</b> on line <b>963</b>
exchangecore replied on at Permalink Reply
A few things.

The Cannot modify header information error you are receiving happens when you try to output something, then change header information. In this case you're trying to print something in your controller, but controllers aren't meant to output things when they have view files (because the view presumably may change header information in this case). If you want to debug, add a die(); statement right after your print statement. PHP 101.

Secondly, the whole reason you're not seeing an updated value is because you're always resetting the value to it's default in your view file. The order of those variables being set would be controller -> view. So sure you are setting it in your controller, but you're overriding it right away on line 4 of your view file.

I think you'll notice that the guide that you linked to, andrew never sets a "default" variable in the view file. If you want to do this you should do it in the controller by doing something like:

if(isset($_POST['uName']) {
    $uName = $_POST['uName'];
} else {
    $uName = 'default value';
$this->set('uNamePosted', $uName);

And finally, there are many documents outlining how to do this sort of thing. I recommend reading over the followiing at a minimum:
There are also numerous forum posts and numerous free add-ons available which you can download and look at for more guidance.
CaptainPanda replied on at Permalink Reply
Thanks, not sure how I missed that, I have read those tutorials but they don't seem to clarify anything :\

Thanks though.
CaptainPanda replied on at Permalink Reply
Anyone?? This is urgent....