# Redirect back to page with argument?

**URL:** <https://discourse.slimframework.com/t/redirect-back-to-page-with-argument/469>\
**Category:** Questions\
**Created:** [July 3, 2016, 8:16pm UTC](https://discourse.slimframework.com/t/redirect-back-to-page-with-argument/469 "2016-07-03T20:16:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://discourse.slimframework.com/u/johan)\
**Post date:** [July 3, 2016, 8:16pm UTC](https://discourse.slimframework.com/t/redirect-back-to-page-with-argument/469/1 "2016-07-03T20:16:04Z")

</div>

Hi!

Im trying to redirect back to a form, if the form fails.

In my `route` i have the following

```php
$app->get('/edit/{id:[0-9]+}', 'HomeController:getEditCrud')->setName('view');

```

And that route looks like:

```php
    /**
    * @return view with post
    */
    public function getEditCrud(Request $request, Response $response, $args){
    	$query = $this->pdo->from('notes')->where('note_id', $args['id'])->fetch();
    	return $this->view->render($response, 'edit-crud.twig', ['query' => $query]);
    }

```

And if i want to make a URL to this page, I use `<a href="{{ path_for('view', {id: query.note_id}) }}">edit</a>`

If i exclude `, {id: query.note_id}` i will receive error `Message: An exception has been thrown during the rendering of a template ("Missing data for URL segment: id") in "crud.twig" at line 33.`

I resevice (almost) the same error when trying ti redirect back to the page where this forms is.

```auto
    if ($validation->failed()) 
	    {
	        $this->flash->addMessage('warning', 'Please fill all fields.');
	        return $response->withRedirect($this->router->pathFor('view'));
	    }

```

I get error:

```php
Type: InvalidArgumentException
Message: Missing data for URL segment: id

```

**Question**  
So my question is, how do i add the ID segment when redirecting?

---

<div class="post-metadata">

**Author:** ![ziriusph](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/ziriusph/32/97_2.png) [@ziriusph](https://discourse.slimframework.com/u/ziriusph)\
**Post date:** [July 3, 2016, 10:50pm UTC](https://discourse.slimframework.com/t/redirect-back-to-page-with-argument/469/2 "2016-07-03T22:50:27Z")

</div>

```
return $response->withRedirect($this->router->pathFor('view', [
    'id' => 'id'
])
```
