#Livewire form submit method?

14 messages · Page 1 of 1 (latest)

mighty osprey
#

Hi. Livewire newbie here. I'm trying to get a page to submit a form to the server. I expected it to be a POST request, but it's a GET which doesn't feel that appropriate for a login form.. I guess I need to change the submission method, so is there a Livewire way of doing that?

frank hawk
#

Yes! You can have a livewire component for the login and register routes.

You can easily use the Auth facade to process the form input and make the login request, all within the same component

#

Hope this serves you!
Have a great day 🙂

mighty osprey
#

Thank you very much, appreciate it!

#

One more thing came up, should I move it to a new thread?

My livewire component has this rules() method, with the one for tenants being a function from a validation in laravel.

public function rules(): array {
  return [
    'email' => ['required', 'string'],
    'password' => ['required', 'string'],
    'tenant' => [
               'required',
               'string', 
               'exists:tenants,id', 
               function ($attribute, $value, $fail) { ... }
  ];
}

Do rules like that work for liveview? It seems they don't, the function doesn't seem to run.

frank hawk
#

Yes they do, however the syntax is slightly different

#

You can either validate it in your method or you could create a custom validation rule in laravel and use that one, this is the recommended approach I would say

#

php artisan make:rule ValidTenant

#

You can create the validation you want there

#

Then use it like this