← All changes
|
backend/src/ValueObjects/Field/FieldGeneralSettings.php
+109
-6
0.8.2
→
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 | /** |
| @@ -116,8 +115,20 @@ | ||
| 116 | 115 | * Whether to show text labels alongside rating. |
| 117 | 116 | * @var bool |
| 118 | 117 | */ |
| 119 | 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; | |
| 120 | 131 | |
| 121 | 132 | /** |
| 122 | 133 | * Public constructor |
| 123 | 134 | * |
| @@ -136,13 +147,17 @@ | ||
| 136 | 147 | * @param bool $phoneAutoDetect |
| 137 | 148 | * @param float|null $minValue |
| 138 | 149 | * @param float|null $maxValue |
| 139 | 150 | * @param float $step |
| 151 | + * @param bool $showGrid | |
| 140 | 152 | * @param string $numberFormat |
| 153 | + * @param ConfirmationGeneralSettings $confirmationSettings | |
| 141 | 154 | * @param TimeFieldGeneralSettings $timeSettings |
| 142 | 155 | * @param DateFieldGeneralSettings $dateSettings |
| 143 | 156 | * @param bool $visible |
| 144 | 157 | * @param bool $showRatingText |
| 158 | + * @param string $htmlContent | |
| 159 | + * @param bool $limitRange | |
| 145 | 160 | */ |
| 146 | 161 | /** |
| 147 | 162 | * @SuppressWarnings("ExcessiveParameterList") |
| 148 | 163 | * @SuppressWarnings("BooleanArgumentFlag") |
| @@ -163,14 +178,18 @@ | ||
| 163 | 178 | bool $phoneAutoDetect, |
| 164 | 179 | ?float $minValue, |
| 165 | 180 | ?float $maxValue, |
| 166 | 181 | float $step, |
| 182 | + bool $showGrid, | |
| 167 | 183 | string $numberFormat, |
| 168 | 184 | ConfirmationGeneralSettings $confirmationSettings, |
| 169 | 185 | TimeFieldGeneralSettings $timeSettings, |
| 170 | 186 | DateFieldGeneralSettings $dateSettings, |
| 171 | 187 | bool $showRatingText, |
| 172 | - bool $visible = true | |
| 188 | + bool $visible = true, | |
| 189 | + string $htmlContent = '', | |
| 190 | + string $agreementText = '', | |
| 191 | + bool $limitRange = false | |
| 173 | 192 | ) { |
| 174 | 193 | $this->label = $label; |
| 175 | 194 | $this->required = $required; |
| 176 | 195 | $this->placeholder = $placeholder; |
| @@ -186,14 +205,18 @@ | ||
| 186 | 205 | $this->phoneAutoDetect = $phoneAutoDetect; |
| 187 | 206 | $this->minValue = $minValue; |
| 188 | 207 | $this->maxValue = $maxValue; |
| 189 | 208 | $this->step = $step; |
| 209 | + $this->showGrid = $showGrid; | |
| 190 | 210 | $this->numberFormat = $numberFormat; |
| 191 | 211 | $this->visible = $visible; |
| 192 | 212 | $this->confirmationSettings = $confirmationSettings; |
| 193 | 213 | $this->timeSettings = $timeSettings; |
| 194 | 214 | $this->dateSettings = $dateSettings; |
| 215 | + $this->htmlContent = $htmlContent; | |
| 195 | 216 | $this->showRatingText = $showRatingText; |
| 217 | + $this->agreementText = $agreementText; | |
| 218 | + $this->limitRange = $limitRange; | |
| 196 | 219 | } |
| 197 | 220 | |
| 198 | 221 | /** |
| 199 | 222 | * Get the label. |
| @@ -429,8 +452,28 @@ | ||
| 429 | 452 | $this->step = $step; |
| 430 | 453 | } |
| 431 | 454 | |
| 432 | 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 | + /** | |
| 433 | 476 | * Get the number format. |
| 434 | 477 | * |
| 435 | 478 | * @return string |
| 436 | 479 | */ |
| @@ -449,8 +492,27 @@ | ||
| 449 | 492 | $this->numberFormat = $numberFormat; |
| 450 | 493 | } |
| 451 | 494 | |
| 452 | 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 | + /** | |
| 453 | 515 | * Get showRatingText flag. |
| 454 | 516 | * @return bool |
| 455 | 517 | */ |
| 456 | 518 | public function isShowRatingText(): bool |
| @@ -468,8 +530,45 @@ | ||
| 468 | 530 | $this->showRatingText = (bool)$val; |
| 469 | 531 | } |
| 470 | 532 | |
| 471 | 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 | + /** | |
| 472 | 571 | * @return array<string, mixed> |
| 473 | 572 | */ |
| 474 | 573 | public function toArray(): array |
| 475 | 574 | { |
| @@ -490,11 +589,15 @@ | ||
| 490 | 589 | 'phoneAutoDetect' => $this->isPhoneAutoDetect(), |
| 491 | 590 | 'minValue' => $this->getMinValue(), |
| 492 | 591 | 'maxValue' => $this->getMaxValue(), |
| 493 | 592 | 'step' => $this->getStep(), |
| 593 | + 'showGrid' => $this->getShowGrid(), | |
| 494 | 594 | 'numberFormat' => $this->getNumberFormat(), |
| 495 | 595 | 'visible' => $this->isVisible(), |
| 496 | 596 | 'showRatingText' => $this->isShowRatingText(), |
| 597 | + 'htmlContent' => $this->getHtmlContent(), | |
| 598 | + 'agreementText' => $this->getAgreementText(), | |
| 599 | + 'limitRange' => $this->isLimitRange(), | |
| 497 | 600 | ], |
| 498 | 601 | $this->confirmationSettings->toArray(), |
| 499 | 602 | $this->timeSettings->toArray(), |
| 500 | 603 | $this->dateSettings->toArray() |