Skip to content

Conversation

@GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Nov 13, 2025

Important

There are multiple commits on purpose. DO NOT SQUASH

  1. ENH Add schema type for special form fields
    Adds new FormField::SCHEMA_DATA_TYPE_STRUCTURAL_CUSTOM const.
    Not strictly necessary as we could just refer to it as a hardcoded string in the admin PR - but adding this here seems consistent with the other SCHEMA_DATA_TYPE consts (which one day maybe we'll turn into an enum)
  2. ENH Allow fields to pass actions down to child-fields
    Adds a new interface and uses it in various places to allow the following behaviours for weirdly-nested fields (in a way that doesn't break that nesting e.g. intentionally doesn't find them for reordering or removing fields):
    • save data from the field into some record
    • fetch data from some record and set the value in the field
    • find the field when handling AJAX requests for form fields (e.g. TreeDropdownField's tree action)
  3. API Move fieldset-related API into new trait
    Not strictly necessary but allows for the new dependent composite field to be a div or a fieldset depending on the use case. Nice to have.
  4. API Add getSourceList() method to searchable dropdowns
    Makes testing the admin PR easier and seems like sensible API to add, but I can work around it if there's any controversy about it.
  5. MNT Update FormFieldTest to account for DependentCompositeField

Of these only 2 and 5 are strictly necessary - but the others make the implementation and tests a little cleaner.

I have also raised #11927 to eventually use the new ChildFieldManager interface in MoneyField.

Issue

@GuySartorelli GuySartorelli marked this pull request as draft November 13, 2025 03:52
@GuySartorelli GuySartorelli force-pushed the pulls/6/dependent-field-stuff branch 2 times, most recently from fe3ff59 to be9a09a Compare November 18, 2025 01:41
@GuySartorelli GuySartorelli force-pushed the pulls/6/dependent-field-stuff branch 6 times, most recently from a43b4c6 to 4dfc114 Compare December 1, 2025 03:26
@GuySartorelli GuySartorelli marked this pull request as ready for review December 1, 2025 03:27
@GuySartorelli GuySartorelli force-pushed the pulls/6/dependent-field-stuff branch from 4dfc114 to b0525ef Compare December 1, 2025 23:06
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API here was moved into FieldSetTrait

Comment on lines -130 to +175
$this->fieldNameError($field, __FUNCTION__);
$this->fieldNameError($field, 'saveableFields');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__FUNCTION__ is the anonymous function - we want the name of the method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API here is from CompositeField and therefore can't be strictly typed without breaking BC

@GuySartorelli GuySartorelli force-pushed the pulls/6/dependent-field-stuff branch 2 times, most recently from 4f6a6da to bea37d1 Compare December 3, 2025 04:27
Currently this is managed through dataFieldByName() and recursiveWalk()
- but those both rely on the field with children explicitly being a
  CompositeField.

I don't want to rely on these, because:
1. recalculating the children
fields for the new dependency field (see admin PR) may be
computationally expensive in some scenarios and we want to avoid calling
it too much.
2. allowing access to children fields too widely for the new field will
   cause all sorts of problems, e.g. calling `replaceField()` or
`renameField()` on a FieldList.
CompositeField has API that lets it change between a `div` and a HTML
`fieldset`. Moving this into a trait lets other fields behave the same
way without having to inherit everything about CompositeField.
This can be useful for checking the current class the dropdown holds,
similar to `getSourceObject()` on a tree dropdown
@GuySartorelli GuySartorelli force-pushed the pulls/6/dependent-field-stuff branch from bea37d1 to 88d27da Compare December 3, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant