Skip to content

Rules error in blade component #98

@evaleries

Description

@evaleries

Describe the bug
Basically if we want to implement client-side validation we can do like Aire::open()->rules('key value of rules') or via blade component like <x-aire::form :rules="$rules"/>. Unfortunately, it didn't work as expected when I use blade component. I got an error Cannot unpack array with string keys.

My solutions are:

  1. Use {{Aire::open()->rules($rules)}}
  2. If we wanna use the blade component, make sure that we wrap the $rules with an array bracket ([$rules]). e.g: <x-aire::form :rules="[$rules]" />

My $rules variable:

$rules = [
     'full_name' => 'required|string'
];

Have you published the Aire config file?
No

Have you added custom Aire views?
No

What version does this affect?

  • Laravel Version: 8.77.1
  • Aire Version: 2.4

To Reproduce
Steps to reproduce the behavior:

  1. Create a blade view. Let's name it as form.blade.php.
  2. Edit form.blade.php with content below:
<x-aire::form :rules="$rules">
    <x-aire::input name="full_name" />
</x-aire::form>
  1. Create a new route in web.php. Route::view('/test', 'form');
  2. Visit /test/ and see the error.

Expected behavior
I expect the same result as I use Aire::form()->rules($rules) and <x-aire::form :rules="$rules"/>.

Additional context
OOC. How do I manually trigger the client-side validation? Like Aire.validate(). I tried the client-side validation but it didn't work.

Thank you for this package. I ❤️ it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions