Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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
Terms</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?
Sign in</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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(