diff --git a/src/Calc/Valid.php b/src/Calc/Valid.php index afddcda..942268f 100644 --- a/src/Calc/Valid.php +++ b/src/Calc/Valid.php @@ -72,13 +72,15 @@ class Valid if($this->engine->getVariables()[$option->getId()] == $opt->getId()) { $opt->setIsSelected(true); + }else{ + $opt->setIsSelected(false); } if($opt->isValid() && !$valid) { $valid = true; } } - + $option->processValue(); $option->setIsValid($valid); } diff --git a/src/Option/Type/PaperDbSelect.php b/src/Option/Type/PaperDbSelect.php index 456b004..0abde89 100644 --- a/src/Option/Type/PaperDbSelect.php +++ b/src/Option/Type/PaperDbSelect.php @@ -22,6 +22,7 @@ class PaperDbSelect extends Select $opt->setId($this->savedCalcValues[$this->getId()]['art_nr']); $opt->setLabel($this->savedCalcValues[$this->getId()]['description_1']); + $paper = $this->newPaperObject; $paper->setId($this->savedCalcValues[$this->getId()]['id']); $paper->setArtNr($this->savedCalcValues[$this->getId()]['art_nr']); @@ -37,6 +38,8 @@ class PaperDbSelect extends Select $opt->setPaper($paper); + $this->addOption($opt); + return $opt; } } diff --git a/src/Option/Type/Select.php b/src/Option/Type/Select.php index ea448a6..b7f817e 100644 --- a/src/Option/Type/Select.php +++ b/src/Option/Type/Select.php @@ -37,12 +37,9 @@ class Select extends Base */ public function processValue() { - /** @var Opt $opt */ - foreach($this->options as $opt) - { - if($opt->getId() == $this->getRawValue()) { - $this->setValue($opt->getLabel()); - } + $option = $this->getSelectedOption(); + if($option) { + $this->setValue($option->getLabel()); } } diff --git a/tests/Complex/PaperSavedTest.php b/tests/Complex/PaperSavedTest.php index 77ad138..97d5c51 100644 --- a/tests/Complex/PaperSavedTest.php +++ b/tests/Complex/PaperSavedTest.php @@ -52,5 +52,7 @@ class PaperSavedTest extends \PHPUnit_Framework_TestCase "offset_fix" => "0", "offset_var" => "0", "digital_fix" => "0", "digital_var" => "0", "volume" => "0.118" ] ]); $this->assertEquals(162.19, $this->engine->getPrice()); + + $this->assertEquals("Bilderdruck matt 250 gr", $this->engine->getArticle()->getOptionById('papier')->getValue()); } } \ No newline at end of file