示例#1
0
 public function setUp()
 {
     parent::setUp();
     $this->specField = SpecField::getNewInstance($this->rootCategory, SpecField::DATATYPE_TEXT, SpecField::TYPE_TEXT_SELECTOR);
     $this->specField->save();
     $this->specFieldAutoIncrementNumber = $this->specField->getID();
     $specFieldValue = SpecFieldValue::getNewInstance($this->specField);
     $specFieldValue->save();
     $this->specFieldValueAutoIncrementNumber = $specFieldValue->getID();
     $this->product = Product::getNewInstance($this->rootCategory, 'test');
     $this->product->save();
     $this->productAutoIncrementNumber = $this->product->getID();
 }
 public function isValid($value)
 {
     if ($this->specField->isMultiValue->get()) {
         $other = $this->request->get('other');
         if (isset($other[$this->specField->getID()][0]) && "" != $other[$this->specField->getID()][0]) {
             return true;
         }
         foreach ($this->specField->getValuesSet() as $value) {
             if ($this->request->isValueSet("specItem_" . $value->getID())) {
                 return true;
             }
         }
     } else {
         if ($this->request->isValueSet($this->specField->getFormFieldName())) {
             return true;
         } else {
             if ('other' == $value) {
                 $other = $this->request->get('other');
                 return !empty($other[$this->specField->getID()]);
             }
         }
     }
     return false;
 }