Source of file ZenValidatorFormFieldExtension.php
Size: 1,128 Bytes - Last Modified: 2021-12-23T10:20:27+00:00
/var/www/docs.ssmods.com/process/src/code/ZenValidatorFormFieldExtension.php
1234567891011121314151617181920212223242526272829303132333435363738 | <?php use SilverStripe\Core\Extension; class ZenValidatorFormFieldExtension extends Extension { /** * @param string $master The name of the form field to respond to * @return ValidationLogicCriteria */ public function validateIf($master) { return $this->owner->validationLogicCriteria = ValidationLogicCriteria::create($this->owner, $master); } /** * Checks to see if any ValidationLogicCriteria has been set and if so, * should the validation constraints still be applied * * @return bool **/ public function validationApplies() { $return = true; /* @var $criteria ValidationLogicCriteria */ if ($criteria = $this->owner->validationLogicCriteria) { $fields = $this->owner->rootFieldList(); if (eval($criteria->phpEvalString()) === false) { throw new Exception("There is a syntax error in the constaint logic phpEvalString \"{$criteria->phpEvalString()}\""); } $return = eval('return ' . $criteria->phpEvalString()); } return $return; } } |