Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

hi i am new in zend framework 2.2.0. i want to create the a link that go to delete page right now i am passing only id in the url so i want to pass another id in it.

<a href="<?php echo $this->url('message',array('action'=>'delete', 'id' => $message->message_id));?>">Add to Trash</a>

right now in this link message id is passing i also want to pass one more id named "did" in this link

<a href="<?php echo $this->url('message',array('action'=>'delete', 'id' => $message->message_id,'did'=>$message->deliver_id));?>">Add to Trash</a>

how can i get this ? thanks in advance

share|improve this question
    
See SO post stackoverflow.com/questions/12785190/… –  kuldeep.kamboj Jun 6 '13 at 5:59
add comment

2 Answers

You should use url view helper's third argument ($options) to pass your variables in the query string. Example:

$route = 'message';
$param = array('action' => 'delete');
$opts  = array(
           'query' => array(
              'id'  => $message->message_id,
              'did' => $message->deliver_id
              )
           );

$this->url($route, $params, $opts);
share|improve this answer
    
I'd suggest this method, too. But it depends on what the URL should look like and how the developer wants to access the params (either via fromRoute() or fromPost()). –  Sam Jun 6 '13 at 9:59
add comment

You have to add "did" to your message route like this:

'router' => array(
    'routes' => array(
        'message' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/:action/:id[/:did]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]+',
                    'id'     => '[0-9]+',
                    'did'    => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                ),
            ),
        ),
    ),
),

echo $this->url('message',array('action'=>'delete', 'id' => $message->message_id,'did'=>$message->deliver_id);
// output: /delete/1/2
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.