This commit is contained in:
Thomas Peterson 2025-06-06 11:44:01 +02:00
parent 6e8a3d1a7f
commit ff0f6ca0d5
5 changed files with 15 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -92,7 +92,7 @@ class Valid
$opt->setIsValid(true); $opt->setIsValid(true);
} }
if(!$opt->isValid() && $opt->getId() == $option->getDefault()) { if(!$opt->isValid() && $opt->getId() == $option->getDefault() && $option->getSelectedOptions()->count() == 0) {
$isDefaultValid = false; $isDefaultValid = false;
} }
@ -144,7 +144,7 @@ class Valid
} }
} }
if($nextShouldBeValid) { if($nextShouldBeValid && $option->getSelectedOptions()->count() === 0) {
foreach($option->getOptions() as $opt) { foreach($option->getOptions() as $opt) {
if($opt->isValid()) { if($opt->isValid()) {
$option->addSelectedOption($opt); $option->addSelectedOption($opt);

View File

@ -10,6 +10,8 @@ class Select extends Base
static public $modeColorDb = 'colordb'; static public $modeColorDb = 'colordb';
static public $modeDelivery = 'delivery'; static public $modeDelivery = 'delivery';
protected $multiSelect = false;
static public $modeNone = ''; static public $modeNone = '';
public $type = 'select'; public $type = 'select';
@ -112,6 +114,15 @@ class Select extends Base
public function addSelectedOption(?Opt $opt): void public function addSelectedOption(?Opt $opt): void
{ {
if(!$this->multiSelect) {
$this->selectedOptions = new \ArrayIterator([$opt]);
return;
}
foreach($this->selectedOptions as $sel) {
if($sel->getId() === $opt->getId()) {
return;
}
}
$this->selectedOptions->append($opt); $this->selectedOptions->append($opt);
} }

View File

@ -56,7 +56,7 @@ class CalcComplexTest extends TestCase
{ {
$this->engine->setVariable('produktart_nopresentationpdf', 2); $this->engine->setVariable('produktart_nopresentationpdf', 2);
$this->engine->calc(); $this->engine->calc();
file_put_contents("/tmp/f1.txt", print_r($this->engine->getVariables(), true).print_r($this->engine->getDebugCalcVariables(), true).print_r($this->engine->getDebugCalcFormel(), true));
$this->assertSame(46.25, $this->engine->getPrice()); $this->assertSame(46.25, $this->engine->getPrice());
} }

View File

@ -39,7 +39,6 @@ class CalcTest extends TestCase
public function testPrice(): void public function testPrice(): void
{ {
$this->engine->calc(); $this->engine->calc();
file_put_contents("/tmp/f1.txt", print_r($this->engine->getVariables(), true).print_r($this->engine->getDebugCalcVariables(), true).print_r($this->engine->getDebugCalcFormel(), true));
self::assertSame(131.86, $this->engine->getPrice()); self::assertSame(131.86, $this->engine->getPrice());
} }