Download the PHP package innoweb/silverstripe-form-validation without Composer
On this page you can find all versions of the php package innoweb/silverstripe-form-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innoweb/silverstripe-form-validation
More information about innoweb/silverstripe-form-validation
Files in innoweb/silverstripe-form-validation
Package silverstripe-form-validation
Short Description Adds Bouncer.js form validation to frontend forms.
License BSD-3-Clause
Informations about the package silverstripe-form-validation
Bouncer.js Form Validation
Introduction
Adds automatic form validation for frontend forms using the Bouncer.js library. This replaces the default HTML5 field validation to improve and unify the layout of error messages accross browsers.
This doesn't replace backend form validation. Backend validation should still be done using the default SS validator (e.g. RequiredFields).
It leaves UserForms forms alone as they are too heavily dependant on jQuery.
Requirements
- SilverStripe ^5
Note: this version is compatible with Silverstripe 5. For Silverstripe 4, please see the 1 release line.
Installation
Install the module using composer:
Then run dev/build.
Configuration
No configuration required. By default, all frontend forms are being validated based on their HTML5 properties.
Disable validation
If you want to exclude a form from validation, you can disable it in code:
This add the class js-no-validation
to the form tag.
To skip validation for specific buttons, you can add the class skip-validation
to the button.
Disable form submission
To disable the default form submission, you can disable it in code:
This adds the class js-disable-submit
to the form tag.
This is useful if you want to submit the form via AJAX. To submit the form, you can listen to the bouncerFormValid
event in JavaScript:
Add Custom Validators
You can inject custom JavaScript validators for certain fields. To do so, you need to extend FormField
as follows:
Use the addCustomValidatorScripts
extension hook to inject your JavaScript validator:
In your field-validation.js
you need to add your validator definition to the global bouncerValidators
variable:
License
BSD 3-Clause License, see License