예제 #1
0
 private function buildItemValidation(RequestValidator $validator, $item, $options, $id = null)
 {
     $name = 'item_' . $item->getID();
     $validator->addCheck($name, new IsNumericCheck($this->translate('_err_not_numeric')));
     $validator->addFilter($name, new NumericFilter());
     $productID = $id ? $id : $item->getProduct()->getID();
     if (isset($options['visible'][$productID])) {
         foreach ($options['visible'][$productID] as $option) {
             if ($option['isRequired']) {
                 $fieldName = $this->getFormFieldName($item, $option);
                 $this->addOptionValidation($validator, $option, $fieldName);
             }
         }
     }
     if (isset($options['more'][$productID])) {
         foreach ($options['more'][$productID] as $option) {
             if ($option['isRequired']) {
                 $field = $this->getFormFieldName($item, $option);
                 if ($this->request->isValueSet($field) || $this->request->isValueSet('checkbox_' . $field)) {
                     $this->addOptionValidation($validator, $option, $field);
                     /*
                     $validator->addCheck($field, new IsNotEmptyCheck($this->translate('_err_option_' . $option['type'])));
                     */
                     if (!$this->request->get($field)) {
                         $_SESSION['optionError'][$item->getID()][$option['ID']] = true;
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 public function addInventoryValidator(RequestValidator $validator)
 {
     if ($this->config->get('INVENTORY_TRACKING') != 'DISABLE') {
         $validator->addCheck('stockCount', new IsNotEmptyCheck($this->translate('_err_stock_required')));
         $validator->addCheck('stockCount', new IsNumericCheck($this->translate('_err_stock_not_numeric')));
         $validator->addCheck('stockCount', new MinValueCheck($this->translate('_err_stock_negative'), 0));
     }
     $validator->addFilter('stockCount', new NumericFilter());
     return $validator;
 }
예제 #3
0
 public function setValidation(RequestValidator $validator, $filtersOnly = false, $fieldPrefix = '')
 {
     $specFields = $this->getSpecificationFieldSet(ActiveRecordModel::LOAD_REFERENCES);
     $application = ActiveRecordModel::getApplication();
     foreach ($specFields as $key => $field) {
         $fieldname = $fieldPrefix . $field->getFormFieldName();
         // validate numeric values
         if (EavFieldCommon::TYPE_NUMBERS_SIMPLE == $field->type->get()) {
             if (!$filtersOnly) {
                 $validator->addCheck($fieldname, new IsNumericCheck($application->translate('_err_numeric')));
             }
             $validator->addFilter($fieldname, new NumericFilter());
         }
         // validate required fields
         if ($field->isRequired->get() && !$filtersOnly) {
             if (!($field->isSelector() && $field->isMultiValue->get())) {
                 $validator->addCheck($fieldname, new IsNotEmptyCheck($application->translate('_err_specfield_required')));
             } else {
                 ClassLoader::import('application.helper.check.SpecFieldIsValueSelectedCheck');
                 $validator->addCheck($fieldname, new SpecFieldIsValueSelectedCheck($application->translate('_err_specfield_multivaluerequired'), $field, $application->getRequest()));
             }
         }
     }
 }
예제 #4
0
 private function setFieldValidation(RequestValidator $validator, Tax $tax, TaxClass $class = null)
 {
     $field = $this->getFieldName($tax, $class);
     $validator->addCheck($field, new IsNumericCheck($this->translate("_error_rate_should_be_numeric_value")));
     $validator->addCheck($field, new MinValueCheck($this->translate("_error_rate_should_be_greater_than_zero"), 0));
     $validator->addFilter($field, new NumericFilter());
 }