← All changes
|
backend/src/ValueObjects/Field/FieldGeneralSettings.php
+137
-6
0.8
→
1.5
View file →
| @@ -6,13 +6,8 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace IvyForms\ValueObjects\Field; |
| 9 | 9 | |
| 10 | -// phpcs:disable PSR1.Files.SideEffects | |
| 11 | -if (!defined('ABSPATH')) { | |
| 12 | - exit; // Exit if accessed directly | |
| 13 | -} | |
| 14 | - | |
| 15 | 10 | use IvyForms\Common\Exceptions\ValidationException; |
| 16 | 11 | use IvyForms\ValueObjects\Field\ConfirmationGeneralSettings; |
| 17 | 12 | use IvyForms\ValueObjects\Field\TimeFieldGeneralSettings; |
| 18 | 13 | use IvyForms\ValueObjects\Field\DateFieldGeneralSettings; |
| @@ -93,8 +88,12 @@ | ||
| 93 | 88 | * @var float Step increment for number fields |
| 94 | 89 | */ |
| 95 | 90 | public float $step; |
| 96 | 91 | /** |
| 92 | + * @var bool Show grid marks on slider | |
| 93 | + */ | |
| 94 | + public bool $showGrid; | |
| 95 | + /** | |
| 97 | 96 | * @var string Number format key |
| 98 | 97 | */ |
| 99 | 98 | public string $numberFormat; |
| 100 | 99 | /** |
| @@ -111,8 +110,25 @@ | ||
| 111 | 110 | * Date settings grouped in a dedicated value object. |
| 112 | 111 | * @var DateFieldGeneralSettings |
| 113 | 112 | */ |
| 114 | 113 | private DateFieldGeneralSettings $dateSettings; |
| 114 | + /** | |
| 115 | + * Whether to show text labels alongside rating. | |
| 116 | + * @var bool | |
| 117 | + */ | |
| 118 | + private bool $showRatingText; | |
| 119 | + /** | |
| 120 | + * @var string HTML content for HTML field type | |
| 121 | + */ | |
| 122 | + private string $htmlContent; | |
| 123 | + /** | |
| 124 | + * @var string Agreement text for GDPR field type | |
| 125 | + */ | |
| 126 | + private string $agreementText; | |
| 127 | + /** | |
| 128 | + * @var bool | |
| 129 | + */ | |
| 130 | + private bool $limitRange; | |
| 115 | 131 | |
| 116 | 132 | /** |
| 117 | 133 | * Public constructor |
| 118 | 134 | * |
| @@ -131,12 +147,17 @@ | ||
| 131 | 147 | * @param bool $phoneAutoDetect |
| 132 | 148 | * @param float|null $minValue |
| 133 | 149 | * @param float|null $maxValue |
| 134 | 150 | * @param float $step |
| 151 | + * @param bool $showGrid | |
| 135 | 152 | * @param string $numberFormat |
| 153 | + * @param ConfirmationGeneralSettings $confirmationSettings | |
| 136 | 154 | * @param TimeFieldGeneralSettings $timeSettings |
| 137 | 155 | * @param DateFieldGeneralSettings $dateSettings |
| 138 | 156 | * @param bool $visible |
| 157 | + * @param bool $showRatingText | |
| 158 | + * @param string $htmlContent | |
| 159 | + * @param bool $limitRange | |
| 139 | 160 | */ |
| 140 | 161 | /** |
| 141 | 162 | * @SuppressWarnings("ExcessiveParameterList") |
| 142 | 163 | * @SuppressWarnings("BooleanArgumentFlag") |
| @@ -157,13 +178,18 @@ | ||
| 157 | 178 | bool $phoneAutoDetect, |
| 158 | 179 | ?float $minValue, |
| 159 | 180 | ?float $maxValue, |
| 160 | 181 | float $step, |
| 182 | + bool $showGrid, | |
| 161 | 183 | string $numberFormat, |
| 162 | 184 | ConfirmationGeneralSettings $confirmationSettings, |
| 163 | 185 | TimeFieldGeneralSettings $timeSettings, |
| 164 | 186 | DateFieldGeneralSettings $dateSettings, |
| 165 | - bool $visible = true | |
| 187 | + bool $showRatingText, | |
| 188 | + bool $visible = true, | |
| 189 | + string $htmlContent = '', | |
| 190 | + string $agreementText = '', | |
| 191 | + bool $limitRange = false | |
| 166 | 192 | ) { |
| 167 | 193 | $this->label = $label; |
| 168 | 194 | $this->required = $required; |
| 169 | 195 | $this->placeholder = $placeholder; |
| @@ -179,13 +205,18 @@ | ||
| 179 | 205 | $this->phoneAutoDetect = $phoneAutoDetect; |
| 180 | 206 | $this->minValue = $minValue; |
| 181 | 207 | $this->maxValue = $maxValue; |
| 182 | 208 | $this->step = $step; |
| 209 | + $this->showGrid = $showGrid; | |
| 183 | 210 | $this->numberFormat = $numberFormat; |
| 184 | 211 | $this->visible = $visible; |
| 185 | 212 | $this->confirmationSettings = $confirmationSettings; |
| 186 | 213 | $this->timeSettings = $timeSettings; |
| 187 | 214 | $this->dateSettings = $dateSettings; |
| 215 | + $this->htmlContent = $htmlContent; | |
| 216 | + $this->showRatingText = $showRatingText; | |
| 217 | + $this->agreementText = $agreementText; | |
| 218 | + $this->limitRange = $limitRange; | |
| 188 | 219 | } |
| 189 | 220 | |
| 190 | 221 | /** |
| 191 | 222 | * Get the label. |
| @@ -421,8 +452,28 @@ | ||
| 421 | 452 | $this->step = $step; |
| 422 | 453 | } |
| 423 | 454 | |
| 424 | 455 | /** |
| 456 | + * Get the show grid value. | |
| 457 | + * | |
| 458 | + * @return bool | |
| 459 | + */ | |
| 460 | + public function getShowGrid(): bool | |
| 461 | + { | |
| 462 | + return $this->showGrid; | |
| 463 | + } | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * Set the show grid value. | |
| 467 | + * | |
| 468 | + * @param bool $showGrid | |
| 469 | + */ | |
| 470 | + public function setShowGrid(bool $showGrid): void | |
| 471 | + { | |
| 472 | + $this->showGrid = $showGrid; | |
| 473 | + } | |
| 474 | + | |
| 475 | + /** | |
| 425 | 476 | * Get the number format. |
| 426 | 477 | * |
| 427 | 478 | * @return string |
| 428 | 479 | */ |
| @@ -441,8 +492,83 @@ | ||
| 441 | 492 | $this->numberFormat = $numberFormat; |
| 442 | 493 | } |
| 443 | 494 | |
| 444 | 495 | /** |
| 496 | + * Get the HTML content. | |
| 497 | + * @return string | |
| 498 | + */ | |
| 499 | + public function getHtmlContent(): string | |
| 500 | + { | |
| 501 | + return $this->htmlContent; | |
| 502 | + } | |
| 503 | + | |
| 504 | + /** | |
| 505 | + * Set the HTML content. | |
| 506 | + * | |
| 507 | + * @param string $htmlContent | |
| 508 | + */ | |
| 509 | + public function setHtmlContent(string $htmlContent): void | |
| 510 | + { | |
| 511 | + $this->htmlContent = $htmlContent; | |
| 512 | + } | |
| 513 | + | |
| 514 | + /** | |
| 515 | + * Get showRatingText flag. | |
| 516 | + * @return bool | |
| 517 | + */ | |
| 518 | + public function isShowRatingText(): bool | |
| 519 | + { | |
| 520 | + return $this->showRatingText; | |
| 521 | + } | |
| 522 | + | |
| 523 | + /** | |
| 524 | + * Set showRatingText flag. | |
| 525 | + * | |
| 526 | + * @param bool|null $val | |
| 527 | + */ | |
| 528 | + public function setShowRatingText(?bool $val): void | |
| 529 | + { | |
| 530 | + $this->showRatingText = (bool)$val; | |
| 531 | + } | |
| 532 | + | |
| 533 | + /** | |
| 534 | + * Get the agreement text. | |
| 535 | + * @return string | |
| 536 | + */ | |
| 537 | + public function getAgreementText(): string | |
| 538 | + { | |
| 539 | + return $this->agreementText; | |
| 540 | + } | |
| 541 | + | |
| 542 | + /** | |
| 543 | + * Set the agreement text. | |
| 544 | + * | |
| 545 | + * @param string $agreementText | |
| 546 | + */ | |
| 547 | + public function setAgreementText(string $agreementText): void | |
| 548 | + { | |
| 549 | + $this->agreementText = $agreementText; | |
| 550 | + } | |
| 551 | + | |
| 552 | + /** | |
| 553 | + * Get limitRange. | |
| 554 | + * @return bool | |
| 555 | + */ | |
| 556 | + public function isLimitRange(): bool | |
| 557 | + { | |
| 558 | + return $this->limitRange; | |
| 559 | + } | |
| 560 | + | |
| 561 | + /** | |
| 562 | + * Set limitRange. | |
| 563 | + * @param bool $limitRange | |
| 564 | + */ | |
| 565 | + public function setLimitRange(bool $limitRange): void | |
| 566 | + { | |
| 567 | + $this->limitRange = $limitRange; | |
| 568 | + } | |
| 569 | + | |
| 570 | + /** | |
| 445 | 571 | * @return array<string, mixed> |
| 446 | 572 | */ |
| 447 | 573 | public function toArray(): array |
| 448 | 574 | { |
| @@ -463,10 +589,15 @@ | ||
| 463 | 589 | 'phoneAutoDetect' => $this->isPhoneAutoDetect(), |
| 464 | 590 | 'minValue' => $this->getMinValue(), |
| 465 | 591 | 'maxValue' => $this->getMaxValue(), |
| 466 | 592 | 'step' => $this->getStep(), |
| 593 | + 'showGrid' => $this->getShowGrid(), | |
| 467 | 594 | 'numberFormat' => $this->getNumberFormat(), |
| 468 | 595 | 'visible' => $this->isVisible(), |
| 596 | + 'showRatingText' => $this->isShowRatingText(), | |
| 597 | + 'htmlContent' => $this->getHtmlContent(), | |
| 598 | + 'agreementText' => $this->getAgreementText(), | |
| 599 | + 'limitRange' => $this->isLimitRange(), | |
| 469 | 600 | ], |
| 470 | 601 | $this->confirmationSettings->toArray(), |
| 471 | 602 | $this->timeSettings->toArray(), |
| 472 | 603 | $this->dateSettings->toArray() |