I
I
Ilya2015-07-31 19:46:53
Laravel
Ilya, 2015-07-31 19:46:53

How to insert anchor into laravel routing?

After filling out the form, you need to insert anchor (anchor) #spasibo into the address bar.
<form action="/order/<?= $item->id ?>#spasibo">
How to handle such a link in routing?

Route::post('/order/{item}', '[email protected]');

Gives an error message.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Akhmadullin, 2015-07-31
@hrhr99

The anchor is not transmitted to the server at all :) This is purely for the browser. If you want to send something to the server - write like this:
On the server, respectively, the code will be as follows:

Route::get('/order/{item}', function() {

    $spasibo = isset($_GET['spasibo']);  // Вернёт boolean в переменную spasibo

});

A
Alexey Ukolov, 2015-07-31
@alexey-m-ukolov

What error does it give? Judging by your code, you submit the form via GET (since the method is not explicitly specified in the form), and the route listens to POST. Hence the error.
You can try doing this: /order/<?= $item->id ?>/#spasibo
In general, the anchor should be ignored by the server, it's client information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question