| @@ -1,13 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Entity\Field; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\ValueObjects\Field\Field as FieldValueObject; |
| 11 | 6 | use IvyForms\Entity\Field\FieldGeneralSettings; |
| 12 | 7 | use IvyForms\Entity\Field\FieldAdvancedSettings; |
| 13 | 8 | |
| @@ -58,8 +53,16 @@ | ||
| 58 | 53 | $this->additionalProperties = apply_filters('ivyforms/field/entity/init_additional_properties', [], $this); |
| 59 | 54 | } |
| 60 | 55 | |
| 61 | 56 | /** |
| 57 | + * Underlying field value object (used by Pro extension hooks). | |
| 58 | + */ | |
| 59 | + public function getFormField(): FieldValueObject | |
| 60 | + { | |
| 61 | + return $this->formField; | |
| 62 | + } | |
| 63 | + | |
| 64 | + /** | |
| 62 | 65 | * Get the ID of the form to which this field belongs |
| 63 | 66 | * |
| 64 | 67 | * @return int The form ID. |
| 65 | 68 | */ |
| @@ -238,8 +241,28 @@ | ||
| 238 | 241 | $this->formField->parentId = $parentId; |
| 239 | 242 | } |
| 240 | 243 | |
| 241 | 244 | /** |
| 245 | + * Get the page ID for multi-page forms. | |
| 246 | + * | |
| 247 | + * @return string|null The page ID. | |
| 248 | + */ | |
| 249 | + public function getPageId(): ?string | |
| 250 | + { | |
| 251 | + return $this->formField->pageId; | |
| 252 | + } | |
| 253 | + | |
| 254 | + /** | |
| 255 | + * Set the page ID for multi-page forms. | |
| 256 | + * | |
| 257 | + * @param string|null $pageId The page ID to set. | |
| 258 | + */ | |
| 259 | + public function setPageId(?string $pageId): void | |
| 260 | + { | |
| 261 | + $this->formField->pageId = $pageId; | |
| 262 | + } | |
| 263 | + | |
| 264 | + /** | |
| 242 | 265 | * Set the number of rows (for textarea fields). |
| 243 | 266 | * |
| 244 | 267 | * @param int $rows |
| 245 | 268 | */ |
| @@ -328,13 +351,18 @@ | ||
| 328 | 351 | 'rowIndex' => $this->getRowIndex(), |
| 329 | 352 | 'columnIndex' => $this->getColumnIndex(), |
| 330 | 353 | 'width' => $this->getWidth(), |
| 331 | 354 | 'parentId' => $this->getParentId(), |
| 355 | + 'pageId' => $this->getPageId(), | |
| 332 | 356 | 'rows' => $this->formField->getRows() |
| 333 | 357 | ], |
| 334 | 358 | $this->getFieldGeneralSettings()->toArray(), |
| 335 | 359 | $this->getFieldAdvancedSettings()->toArray() |
| 336 | 360 | ); |
| 361 | + | |
| 362 | + foreach ($this->additionalProperties as $property) { | |
| 363 | + $data = array_merge($data, $property); | |
| 364 | + } | |
| 337 | 365 | |
| 338 | 366 | /** |
| 339 | 367 | * Allows modification of the array representation of the Field entity. |
| 340 | 368 | * @since 0.1.0 |