Source of file QuantityField.php
Size: 0,925 Bytes - Last Modified: 2021-12-24T05:16:32+00:00
/var/www/docs.ssmods.com/process/src/code/forms/QuantityField.php
123456789101112131415161718192021222324252627282930313233343536373839404142 | <?php /** * Text input field with validation for numeric values. * * @package forms * @subpackage fields-formattedinput */ class QuantityField extends NumericField{ public function Type() { return 'quantity numeric text'; } /** PHP Validation **/ public function validate($validator){ if($this->value && !is_numeric(trim($this->value))){ $validator->validationError( $this->name, _t( 'NumericField.VALIDATION', "'{value}' is not a number, only numbers can be accepted for this field", array('value' => $this->value) ), "validation" ); return false; } elseif(!$this->value) { $validator->validationError( $this->name, sprintf(_t('Form.FIELDISREQUIRED', '%s is required'), $this->title), "validation" ); return false; } else { return true; } } public function dataValue() { return (is_numeric($this->value)) ? $this->value : 0; } } |