Allow extending fields to share methods - #709
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors field rendering and validation by replacing legacy property access (using get()) with dedicated method calls, and it introduces support for extending fields via shared methods. Key changes include switching method calls (e.g. options(), minLength(), etc.), updating error validation messages, and adding an extension‐merging mechanism in the FieldFactory.
Reviewed Changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| panel/views/fields/*.php | Refactored field attribute access to use dedicated methods (e.g., options(), rows()). |
| formwork/fields/*.php & FieldFactory.php | Updated field configuration to support method extensions through an “extend” key. |
Comments suppressed due to low confidence (2)
formwork/src/Fields/FieldFactory.php:37
- The extension merging loop does not currently guard against potential circular extension configurations. Adding a safeguard to detect and break out of circular dependencies would prevent potential infinite loops.
while ($extend !== $type) {
| throw new ValidationException(sprintf('The value of field "%s" of type "%s" must be less than or equal to %d', $field->name(), $field->type(), $field->get('max'))); | ||
| } | ||
|
|
||
| if ($field->has('step') && ($value - $field->get('min', 0)) % $field->step() !== 0) { |
There was a problem hiding this comment.
[nitpick] For consistency with the new API, consider replacing $field->get('min', 0) with $field->min() if such a method exists, ensuring uniform usage throughout the code.
| if ($field->has('step') && ($value - $field->get('min', 0)) % $field->step() !== 0) { | |
| if ($field->has('step') && ($value - $field->min()) % $field->step() !== 0) { |
No description provided.