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

  • Home
  • SEARCH
  • 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 6611299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:57:09+00:00 2026-05-25T19:57:09+00:00

I have a a controller referral_medium_controller.php with the following content <?php class ReferralMediumsController extends

  • 0

I have a a controller referral_medium_controller.php with the following content

<?php
class ReferralMediumsController extends AppController
{
    var $name = 'ReferralMediums';

    function admin_index() 
    {
        //Checking that only super administrators can actually add new interest options
        if ($this->Auth->user('user_type_id') != ConstUserTypes::Admin) {
            $this->cakeError('error404');
        }

        $this->pageTitle = __l('Referral Mediums');
        $this->ReferralMediums->recursive = 0;
        $this->set('ReferralMediums', $this->paginate());
    }
    function admin_view($id = null) 
    {
        //Checking that only super administrators can actually add new interest options
        if ($this->Auth->user('user_type_id') != ConstUserTypes::Admin) {
            $this->cakeError('error404');
        }
        $this->pageTitle = __l('Referral Mediums?');
        if (is_null($id)) {
            $this->cakeError('error404');
        }
        $referralMedium = $this->ReferralMediums->find('first', array(
            'conditions' => array(
                'ReferralMedium.id = ' => $id
            ) ,
            'fields' => array(
                'ReferralMedium.id',
                'ReferralMedium.created',
                'ReferralMedium.modified',
                'ReferralMedium.referral_medium',
                'ReferralMedium.is_active',
            ) ,
            'recursive' => -1,
        ));
        if (empty($referralMedium)) {
            $this->cakeError('error404');
        }
        $this->pageTitle.= ' - ' . $referralMedium['ReferralMedium']['id'];
        $this->set('ReferralMediums', $referralMedium);
    }
    function admin_add() 
    {
        //Checking that only super administrators can actually add new interest options
        if ($this->Auth->user('user_type_id') != ConstUserTypes::Admin) {
            $this->cakeError('error404');
        }
        $this->pageTitle = __l('Add Referral Medium');
        if (!empty($this->data)) {
            $this->ReferralMedium->create();
            if ($this->ReferralMedium->save($this->data)) {
                $this->Session->setFlash(__l('Referral Medium has been added') , 'default', null, 'success');
                $this->redirect(array(
                    'action' => 'index'
                ));
            } else {
                $this->Session->setFlash(__l('Referral Medium could not be added. Please, try again.') , 'default', null, 'error');
            }
        }
    }
    function admin_edit($id = null) 
    {
        //Checking that only super administrators can actually add new interest options
        if ($this->Auth->user('user_type_id') != ConstUserTypes::Admin) {
            $this->cakeError('error404');
        }
        $this->pageTitle = __l('Edit Referral Medium');
        if (is_null($id)) {
            $this->cakeError('error404');
        }
        if (!empty($this->data)) {
            if ($this->ReferralMedium->save($this->data)) {
                $this->Session->setFlash(__l('Referral Medium has been updated') , 'default', null, 'success');
                $this->redirect(array(
                    'action' => 'index'
                ));
            } else {
                $this->Session->setFlash(__l('Referral Medium could not be updated. Please, try again.') , 'default', null, 'error');
            }
        } else {
            $this->data = $this->ReferralMedium->read(null, $id);
            if (empty($this->data)) {
                $this->cakeError('error404');
            }
        }
        $this->pageTitle.= ' - ' . $this->data['ReferralMedium']['id'];
    }
    function admin_delete($id = null) 
    {
        //Checking that only super administrators can actually add new interest options
        if ($this->Auth->user('user_type_id') != ConstUserTypes::Admin) {
            $this->cakeError('error404');
        }
        if (is_null($id)) {
            $this->cakeError('error404');
        }
        if ($this->ReferralMedium->del($id)) {
            $this->Session->setFlash(__l('Referral Medium deleted') , 'default', null, 'success');
            $this->redirect(array(
                'action' => 'index'
            ));
        } else {
            $this->cakeError('error404');
        }
    }
}
?>

a model referral_model.php with the following content

<?php
class ReferralMedium extends AppModel
{
    var $name = 'ReferralMedium';

    var $useTable="referral_mediums";

    //$validate set in __construct for multi-language support
    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $hasOne = array(
        'UserProfile' => array(
            'className' => 'UserProfile',
            'foreignKey' => 'referral_medium_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );
    var $hasMany = array(
        'UserProfile' => array(
            'className' => 'UserProfile',
            'foreignKey' => 'referral_medium_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );
    function __construct($id = false, $table = null, $ds = null) 
    {
        parent::__construct($id, $table, $ds);
        $this->validate = array(
            'referral_medium' => array(
                'rule' => 'notempty',
                'allowEmpty' => false,
                'message' => __l('Required')
            ) ,
        );
    }
}
?>

a add view referral_mediums/admin_add.ctp with the following code

<?php /* SVN: $Id: $ */ ?>
<div class="referralMedium form">
<?php echo $form->create('ReferralMedium', array('class' => 'normal'));?>
    <fieldset>
        <h2><?php echo __l('Add Referral Medium');?></h2>
    <?php
        echo $form->input('referral_medium');
        echo $form->input('is_active');
    ?>
    </fieldset>

   <div class="submit-block clearfix">
    <?php echo $form->submit(__l('Add'));?>
    </div>
    <?php echo $form->end();?>
</div>

Now all works fine except if I click on the add button in the add form I get redirected to admin/referral_media/add instead of admin/referral_medium/add and I can’t find the problem. I would be greatful I someone could help me with this.

  • 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-05-25T19:57:10+00:00Added an answer on May 25, 2026 at 7:57 pm

    the plural of medium is media, not mediums. The controller name is plural, so it’s referral_media. So you’ll need to change your controller name (and the file name).

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

Sidebar

Related Questions

I have this controller set up for a login: <?php class Login extends Controller
I have controller and it has following code: class Company_ModuleName_NameController extends Mage_Core_Controller_Front_Action { public
I have controller: package plugin class TestController { def simply = {[name:new Date()]} }
i have controller class UserController (in controller folder) which extends BaseController (present in app
I have a controller with an action method as follows: public class InventoryController :
I have a controller class which spawns a window when a certain condition occurs.
I have a controller called MetricsController with a single action method: public class MetricsController
If user hits http://somewebsite/Cnt but i dont have controller with that name and i
I have the following routes defined for my application: routes.MapRoute( Referral, // Route name
I have controller: class AccountController < ApplicationController def index end private def current_account @current_account

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.