reinisk22's avatar

Cant resolve file, in html forms.

Hey,

I got these routes:

$router->get('/', fn() => view('home'));
$router->post('/', fn() => view('matchHistory'));

and these html pages, home.html:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <h1>Account Name</h1>

    <form method="POST" action="/matchHistory">
        <div>
            <label>
                <input type="text">
            </label>
            <input type="submit" value="Submit">
        </div>
    </form>

</body>
</html>

and matchHistory.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h1>test</h1>
</body>
</html>

But when I press the button Submit, I get an error that the page is not found. Also, the action attribute in the home.html page I posted, is underlined and says cannot resolve file matchHistory.

0 likes
4 replies
Nakov's avatar

First, your endpoint is / and you use a different one on the form.. It should be this

<form method="POST" action="/">

and then where do you have the file? Lumen is used more for API not to load views so I guess that is the other issue. Have you installed the package for the Views?

reinisk22's avatar

@nakov This helped, also, If I set the route to $router->post('/{summoner}', fn() => view('matchHistory')); helped.

No, I havent installed a package. I thought they would work without them. Both of these files are located in resources/views folder.

Please or to participate in this conversation.