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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:22+00:00 2026-06-16T00:34:22+00:00

I have controller with an add action. public function add() { $this->layout = ‘manage’;

  • 0

I have controller with an add action.

public function add() {   
    $this->layout = 'manage';
    $this->set($this->Restaurant->fetchRelatedData());
    if ($this->request->is('post')) {
        $this->Restaurant->create();
        if ($this->Restaurant->save($this->request->data)) {
            $this->Session->setFlash('ok!');
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash('Error!');
        }
    }
}

View for this action created with Form and Js helpers:

echo $this->Form->create('Restaurant');
// some fields
echo $this->Form->input('district_id', array('label' => 'District'));
echo $this->Form->input('street_id', array('label' => 'Street')); 
// other fields
echo $this->Form->end(array('label' => 'Add'));

$this->Js->get('#RestaurantDistrictId')->event('change', 
$this->Js->request(array(
    'controller'=>'streets',
    'action'=>'getByDistrict'
    ), array(
    'update'=>'#RestaurantStreetId',
    'async' => true,
    'method' => 'post',
    'dataExpression'=>true,
    'data'=> $this->Js->serializeForm(array(
        'isForm' => true,
        'inline' => true
        ))
    ))
);

Js helper shows list with streets that are in choosen district.

StreetsController -> getByDistrict action:

public function getByDistrict(){
    $district_id = $this->request->data['Restaurant']['district_id'];
    $streets = $this->Street->find('list', array(
        'conditions' => array('Street.district_id' => $district_id),
        'fields' => array('street'),
        'order' => array('Street'),
        'recursive' => -1,
    ));
    $this->set('streets', $streets);
    $this->layout = 'ajax';
}

Everything worked fine until I added the administrative prefix to this action.
If action is named public function add() – all things works.
If action is named *public function admin_add()* – Js helper stops updating streets list on district change.

  • 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-16T00:34:23+00:00Added an answer on June 16, 2026 at 12:34 am

    I’m not 100% sure on this, but I believe that the JS helper is preserving the admin prefix when it makes the AJAX request. When in add() it would call getByDistrict(). When in admin_add() it would call admin_getByDistrict(). Try passing ‘admin’ => false into Js->request.

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

Sidebar

Related Questions

I have something like this: controller. public function add() { $this->layout = 'home'; $this->Session->destroy();
I have this RegisterRoute function public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.Add(JsActionRoute, JsAction.JsActionRouteHandlerInstance.JsActionRoute);
In my MVC application in Controller i have following function to add and focus
I have a fairly standard .Net MVC Controller method: public ActionResult Add(Customer cust) {
I have controller users . In this controller I have action account which is
I have this Json returned from controller : public ActionResult VerifyApp(string recurrence) { List<foo>
Inside my controller's action I have the following code: public ActionResult GridAction(string id) {
How can i add the session to a fakeContext ? This function have we
I have an entries controller that allows users to add contact information the website.
Let's say I have a simple ASP MVC3 list controller, with an add method,

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.