leafsphp / mvc-core

🌉 Leaf Bridge for Leaf MVC
https://leafphp.dev/modules/mvc-core/
3 stars 4 forks source link

Default Auth Scaffold Validation Problem #17

Open WireNinja opened 1 year ago

WireNinja commented 1 year ago

Describe the bug Failed to catch validation by using auth scaffold in leaf cli. The error message :

 htmlspecialchars(): Argument leafsphp/leaf#1 ($string) must be of type string, array given (View:\app\views\pages\auth\login.blade.php)

Default validation :

// login controller
auth()->guard('guest');

$data = request()->get(['username', 'password']);

$isValid= form()->validate($data, [
    'username' => 'text',
    'password' => 'required',
]);

if (!$isValid) {
    echo view('pages.auth.login', array_merge($data, [
        'errors' => array_merge(
            auth()->errors(),
            form()->errors()
        ),
    ]));
}

// login.blade.php
{{ $errors['password'] ?? null }} // default view, this give me error

{{ $errors['password'][0] ?? null }} // this is working

To Reproduce Steps to reproduce the behavior:

  1. Create new leaf app
  2. Run php leaf auth:scaffold
  3. Go to /auth/login
  4. Hit login button
  5. See error

Expected behavior Validation message should be like this : issue2 Thankyou.