praxisnetau / silverware-validator Goto Github PK
View Code? Open in Web Editor NEWSilverWare Validator Module
License: BSD 3-Clause "New" or "Revised" License
SilverWare Validator Module
License: BSD 3-Clause "New" or "Revised" License
The client side validation don't work with https://github.com/UndefinedOffset/silverstripe-nocaptcha
Hi,
first of all thank you for the module. It is very well done so thank you for that.
There is an issue when trying to use the module in the getCMSValidator() function of an object like so
/**
* CMS Fields
* @return Validator
*/
public function getCMSValidator()
{
$validator = Validator::create();
$validator->setRules(
'Title',
[
RequiredRule::create()
]
);
return $validator;
}
And it is that on the first load of a page when the validator is used it breaks the layout of the page because the parsley file does not load correctly, hence stopping a bunch of SS js files from loading.
When trying that approach the admin looks like this:
then on reload it's fine.
I do not know if you intended your module to be used in this scenario as you don't officially list it in your documentation, however it can definitely be used in this scenario since it implements the Silverstripe Validator abstract. It works very well after the page reload (all the custom rules work too).
Matter of fact I was using it in the getCMSValidator because I found your module coming from the Shea Dawson ZenValidator one (he lists the use as a CMSValidator).
So long story short, the parsley file is the issue, which would not matter in the way I am using the Validator except that it cannot be de-activated in a straightforward way, I know that you have listed
$validator->setClientSide(false);
as an option, however that does not stop parsley from failing to load on ajax request.
Also trying to override the js_required in the Parsley Backend like so
SilverWare\Validator\Backends\ParsleyBackend:
js_required:
- []
does not work because it only adds to the js list.
Luckily you have done well to provide extension hooks so the way I solved this was like such:
class ValidatorFix extends DataExtension
{
public function updateRequiredJS(&$js){
$js = array();
}
}
Which works alright when applied to ParsleyBackend class
.
Sorry for the long description I wanted to make you understand the situation.
Anyway, this is not an issue per se as you already provided devs options to override such behaviour, however I cannot determine why the parsley file conflicts with SS backend so my best suggestion would be the following: if you intend the module to be used as a CMS Validator too I'd suggest that you allow the config file to override the js options completely.
Obviously if you can determine why parsley conflicts it would be even better but I suspect parsley file has a problem in itself (on the ZenValidator page from Shea he has an option to disable the parsley file when the Validator is used in the getCMSValidator function).
Hi,
Is it possible to update Guzzle to version 7.* in the composer file? I get conflicts with other repositories now.
Hi,
Is there an option to validate or not validate a field depending on choice of a optionset field? For example: I have an optionset field with different payment options. Depending of the choice of payment I show or hide fields below by jQuery. If fields are hidden they must not validated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.