| @@ -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 | */ |
| @@ -158,105 +161,105 @@ | ||
| 158 | 161 | $this->formField->position = $position; |
| 159 | 162 | } |
| 160 | 163 | |
| 161 | 164 | /** |
| 162 | - * Get the parent field ID. | |
| 165 | + * Get the row index of the form field. | |
| 163 | 166 | * |
| 164 | - * @return int|null The parent field ID. | |
| 167 | + * @return int The row index of the form field. | |
| 165 | 168 | */ |
| 166 | - public function getParentId(): ?int | |
| 169 | + public function getRowIndex(): int | |
| 167 | 170 | { |
| 168 | - return $this->formField->getParentId(); | |
| 171 | + return $this->formField->getRowIndex(); | |
| 169 | 172 | } |
| 170 | 173 | |
| 171 | 174 | /** |
| 172 | - * Set the parent field ID. | |
| 175 | + * Set the row index of the form field. | |
| 173 | 176 | * |
| 174 | - * @param int|null $parentId The parent field ID to set. | |
| 177 | + * @param int $rowIndex The row index to set. | |
| 175 | 178 | */ |
| 176 | - public function setParentId(?int $parentId): void | |
| 179 | + public function setRowIndex(int $rowIndex): void | |
| 177 | 180 | { |
| 178 | - $this->formField->parentId = $parentId; | |
| 181 | + $this->formField->rowIndex = $rowIndex; | |
| 179 | 182 | } |
| 180 | 183 | |
| 181 | 184 | /** |
| 182 | - * Check if the confirm field feature is enabled. | |
| 185 | + * Get the column index of the form field. | |
| 183 | 186 | * |
| 184 | - * @return bool True if the confirm field feature is enabled, false otherwise. | |
| 187 | + * @return int The column index of the form field. | |
| 185 | 188 | */ |
| 186 | - public function isConfirmFieldEnabled(): bool | |
| 189 | + public function getColumnIndex(): int | |
| 187 | 190 | { |
| 188 | - return $this->formField->isConfirmFieldEnabled(); | |
| 191 | + return $this->formField->getColumnIndex(); | |
| 189 | 192 | } |
| 190 | 193 | |
| 191 | 194 | /** |
| 192 | - * Get the label for the confirmation field. | |
| 195 | + * Set the column index of the form field. | |
| 193 | 196 | * |
| 194 | - * @return string The label for the confirmation field. | |
| 197 | + * @param int $columnIndex The column index to set. | |
| 195 | 198 | */ |
| 196 | - public function getConfirmFieldLabel(): string | |
| 199 | + public function setColumnIndex(int $columnIndex): void | |
| 197 | 200 | { |
| 198 | - return $this->formField->getConfirmFieldLabel(); | |
| 201 | + $this->formField->columnIndex = $columnIndex; | |
| 199 | 202 | } |
| 200 | 203 | |
| 201 | 204 | /** |
| 202 | - * Get the placeholder for the confirmation field. | |
| 205 | + * Get the width percentage of the form field. | |
| 203 | 206 | * |
| 204 | - * @return string The placeholder for the confirmation field. | |
| 207 | + * @return int The width percentage of the form field. | |
| 205 | 208 | */ |
| 206 | - public function getConfirmFieldPlaceholder(): string | |
| 209 | + public function getWidth(): int | |
| 207 | 210 | { |
| 208 | - return $this->formField->getConfirmFieldPlaceholder(); | |
| 211 | + return $this->formField->getWidth(); | |
| 209 | 212 | } |
| 210 | 213 | |
| 211 | 214 | /** |
| 212 | - * Check if the confirmation field label should be hidden. | |
| 215 | + * Set the width percentage of the form field. | |
| 213 | 216 | * |
| 214 | - * @return bool True if the confirmation label should be hidden, false otherwise. | |
| 217 | + * @param int $width The width percentage to set (20-100). | |
| 215 | 218 | */ |
| 216 | - public function isConfirmFieldHideLabel(): bool | |
| 219 | + public function setWidth(int $width): void | |
| 217 | 220 | { |
| 218 | - return $this->formField->isConfirmFieldHideLabel(); | |
| 221 | + $this->formField->width = $width; | |
| 219 | 222 | } |
| 220 | 223 | |
| 221 | 224 | /** |
| 222 | - * Set the enabled status of the confirm field feature. | |
| 225 | + * Get the parent field ID. | |
| 223 | 226 | * |
| 224 | - * @param bool $enabled The enabled status to set. | |
| 227 | + * @return int|null The parent field ID. | |
| 225 | 228 | */ |
| 226 | - public function setConfirmFieldEnabled(bool $enabled): void | |
| 229 | + public function getParentId(): ?int | |
| 227 | 230 | { |
| 228 | - $this->formField->setConfirmFieldEnabled($enabled); | |
| 231 | + return $this->formField->getParentId(); | |
| 229 | 232 | } |
| 230 | 233 | |
| 231 | 234 | /** |
| 232 | - * Set the label for the confirmation field. | |
| 235 | + * Set the parent field ID. | |
| 233 | 236 | * |
| 234 | - * @param string $label The label to set. | |
| 237 | + * @param int|null $parentId The parent field ID to set. | |
| 235 | 238 | */ |
| 236 | - public function setConfirmFieldLabel(string $label): void | |
| 239 | + public function setParentId(?int $parentId): void | |
| 237 | 240 | { |
| 238 | - $this->formField->setConfirmFieldLabel($label); | |
| 241 | + $this->formField->parentId = $parentId; | |
| 239 | 242 | } |
| 240 | 243 | |
| 241 | 244 | /** |
| 242 | - * Set the placeholder for the confirmation field. | |
| 245 | + * Get the page ID for multi-page forms. | |
| 243 | 246 | * |
| 244 | - * @param string $ph The placeholder to set. | |
| 247 | + * @return string|null The page ID. | |
| 245 | 248 | */ |
| 246 | - public function setConfirmFieldPlaceholder(string $ph): void | |
| 249 | + public function getPageId(): ?string | |
| 247 | 250 | { |
| 248 | - $this->formField->setConfirmFieldPlaceholder($ph); | |
| 251 | + return $this->formField->pageId; | |
| 249 | 252 | } |
| 250 | 253 | |
| 251 | 254 | /** |
| 252 | - * Set the hideLabel setting for the confirmation field. | |
| 255 | + * Set the page ID for multi-page forms. | |
| 253 | 256 | * |
| 254 | - * @param bool $hide The hideLabel setting to set. | |
| 257 | + * @param string|null $pageId The page ID to set. | |
| 255 | 258 | */ |
| 256 | - public function setConfirmFieldHideLabel(bool $hide): void | |
| 259 | + public function setPageId(?string $pageId): void | |
| 257 | 260 | { |
| 258 | - $this->formField->setConfirmFieldHideLabel($hide); | |
| 261 | + $this->formField->pageId = $pageId; | |
| 259 | 262 | } |
| 260 | 263 | |
| 261 | 264 | /** |
| 262 | 265 | * Set the number of rows (for textarea fields). |
| @@ -344,18 +347,22 @@ | ||
| 344 | 347 | 'formId' => $this->getFormId(), |
| 345 | 348 | 'fieldIndex' => $this->getIndex(), |
| 346 | 349 | 'type' => $this->getType(), |
| 347 | 350 | 'position' => $this->getPosition(), |
| 351 | + 'rowIndex' => $this->getRowIndex(), | |
| 352 | + 'columnIndex' => $this->getColumnIndex(), | |
| 353 | + 'width' => $this->getWidth(), | |
| 348 | 354 | 'parentId' => $this->getParentId(), |
| 349 | - 'rows' => $this->formField->getRows(), | |
| 350 | - 'confirmFieldEnabled' => $this->isConfirmFieldEnabled(), | |
| 351 | - 'confirmFieldLabel' => $this->getConfirmFieldLabel(), | |
| 352 | - 'confirmFieldPlaceholder' => $this->getConfirmFieldPlaceholder(), | |
| 353 | - 'confirmFieldHideLabel' => $this->isConfirmFieldHideLabel(), | |
| 355 | + 'pageId' => $this->getPageId(), | |
| 356 | + 'rows' => $this->formField->getRows() | |
| 354 | 357 | ], |
| 355 | 358 | $this->getFieldGeneralSettings()->toArray(), |
| 356 | 359 | $this->getFieldAdvancedSettings()->toArray() |
| 357 | 360 | ); |
| 361 | + | |
| 362 | + foreach ($this->additionalProperties as $property) { | |
| 363 | + $data = array_merge($data, $property); | |
| 364 | + } | |
| 358 | 365 | |
| 359 | 366 | /** |
| 360 | 367 | * Allows modification of the array representation of the Field entity. |
| 361 | 368 | * @since 0.1.0 |