Form validation with Laravel Metronic demo7

Please help with form validation.
I want to replicate the register page but form validation is not working

this is my create and store methods

public function create(){
return view('associations.create');
}
// For the association creation
public function store(){

// Make validation
$attributes = request()->validate([
'name'=>['required','max:50'],
'sigle'=>['required','max:10','unique:associations,sigle'],
'description'=>['required']
]);

// Create the Association
Association::create($attributes);

return redirect("/")->with('success','Congratulation');

}

And this is the form :

<x-auth-layout>
<!--begin::Signup Form-->
<form class="form w-100 " novalidate="novalidate" id="kt_sign_up_form" action="{{ route('associations.create') }}">
@csrf
<!--begin::Heading-->
<div class="text-center mb-11">
<!--begin::Title-->
<h1 class="text-dark fw-bolder mb-3">{{ __("Add your first Association") }}</h1>
<!--end::Title-->
<!--begin::Subtitle-->
<div class="text-gray-500 fw-semibold fs-6">{{ __("")}}</div>
<!--end::Subtitle=-->
</div>
<!--begin::Heading-->
<!--end::Login options-->

<!--begin::Input group=-->
<div class="fv-row mb-8 fv-plugins-icon-container fv-plugins-bootstrap5-row-valid">
<input class="form-control form-control-lg form-control-solid" type="text" name="name" autocomplete="off" value="{{ old('name') }}" placeholder="Name of Association here" required/>
</div>
<!--begin::Input group=-->
<div class="fv-row mb-8 fv-plugins-icon-container fv-plugins-bootstrap5-row-valid">
<input class="form-control form-control-lg form-control-solid" type="text" name="sigle" autocomplete="off" value="{{ old('sigle') }}" placeholder="Sigle of Association here"/>
</div>
<!--begin::Input group=-->
<div class="fv-row mb-8 fv-plugins-icon-container fv-plugins-bootstrap5-row-valid">
<!--begin::Email-->
<textarea class="form-control form-control-solid" name="description" placeholder="Type description here">{{ old('description')}}</textarea>
<!--end::Email-->
</div>

<!--begin::Accept-->
<div class="fv-row mb-8 fv-plugins-icon-container">
<label class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" name="toc" value="1">
<span class="form-check-label fw-semibold text-gray-700 fs-base ms-1">I Accept the
<a href="#" class="ms-1 link-primary">Terms</a></span>
</label>
</div>
<!--end::Accept-->
<!--begin::Submit button-->
<div class="d-grid mb-10">
<button type="submit" id="kt_sign_up_submit" class="btn btn-primary">
@include('partials.general._button-indicator')
</button>
</div>
<!--end::Submit button-->
<!--begin::Sign up-->
<div class="text-gray-500 text-center fw-semibold fs-6">Already have an Account?
<a href="{{ theme()->getPageUrl('login') }}" class="link-primary fw-semibold">Sign in</a></div>
<!--end::Sign up-->
<div></div>
</form>
<!--end::Signup Form-->

</x-auth-layout>

The route :
// Associations pages
Route::post('associations.create', [AssociationController::class, 'create']);
Route::get('associations.index', [AssociationController::class, 'index']);
Route::resource('associations', AssociationController::class);

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi

The register form uses this JS file. If you want to replicate it, please update this JS file to match your form inputs and include it in your registration page.

resources/assets/extended/js/custom/authentication/sign-up/general.js

Thanks

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(