1

I have two URLs for one action and each should generate different views.

e.g.: /abc -> connects with controller x, action y, view = 0

/def -> connects with controller x, action y, view = 1

this works fine with

Router::connect('/abc', array('controller' => 'x 'action' => 'y', 'view' => 0));

Router::connect('/def', array('controller' => 'x 'action' => 'y', 'view' => 1));


but now there is that problem:

I have a formular, which should send its data to /def or /abc. How can I manually set, which route should be used?


edit:

$form->create('Model', array('url' => array('action' => 'index', 'view' => '1'))); // def

$form->create('Model', array('url' => array('action' => 'index', 'view' => '0'))); // abc

both leads me to /controller/index and not to /def or /abc

1 Answer 1

2
Router::connect('/def', array('controller' => 'x' action' => 'y', 'view' => 1), array('pass' => array('view')));

then

if($this->params['view']){
   // its 1
} else{
   //its 0
}
Sign up to request clarification or add additional context in comments.

2 Comments

yes, that works for me. but how do i correctly select the target-url for the formular?
$this->Html->link('foo', '/def'); not sure what you asking

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.