Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 914 Bytes

README.md

File metadata and controls

36 lines (26 loc) · 914 Bytes

marko/forms

Server-rendered form round trips for Marko --- redirect back with flashed validation errors and old input, plus csrf_field(), old() and errors() template helpers for Latte and Twig.

Installation

composer require marko/forms

Quick Example

use Marko\Routing\Attributes\Post;

#[Post('/register')]
public function store(Request $request): Response
{
    // On failure: 303 back to the form with the errors and old input flashed
    $this->validator->validateOrFail($request->post(), ['email' => ['required', 'email']]);

    return Response::redirect('/welcome', 303);
}
<form method="post">
    {csrf_field()}
    <input name="email" value={old('email')}>
    {if $errors->has('email')}<p>{$errors->first('email')}</p>{/if}
</form>

Documentation

Full usage, API reference, and examples: marko/forms