Source of file AbcTextCapField.php
Size: 1,077 Bytes - Last Modified: 2022-01-13T10:01:17+00:00
/var/www/docs.ssmods.com/process/src/code/AbcTextCapField.php
12345678910111213141516171819202122232425262728293031323334353637383940414243 | <?php class AbcTextCapField extends TextField { protected $capData = null; protected $template = 'AbcTextCapField'; protected $isValid = null; public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null) { parent::__construct($name, $title, $value, $maxLength, $form); } public function getQuestion(){ if (empty($this->capData)) $this->capData = AbcTextCap::getCapData(); return $this->capData->q; } public function validate($validator) { // extract the value $value = empty($this->value) ? $_REQUEST[$this->name] : $this->value; // validate and save the validation result in case validate gets called twice if ($this->isValid === null) $this->isValid = AbcTextCap::validate($value); // push validation error if (!$this->isValid) { $validator->validationError( $this->name, 'You answered the question incorrectly', "validation", false ); } // reset the question $this->capData = AbcTextCap::getCapData(); return $this->isValid; } } |