Skip to content

Support custom core fields via config - #419

Open
Abdulmajeed-Jamaan wants to merge 7 commits into
4.xfrom
feat/allow-core-fields-configuration
Open

Support custom core fields via config#419
Abdulmajeed-Jamaan wants to merge 7 commits into
4.xfrom
feat/allow-core-fields-configuration

Conversation

@Abdulmajeed-Jamaan

@Abdulmajeed-Jamaan Abdulmajeed-Jamaan commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Support for #413 .

Alternative solution for #414 , Add a new config option 'coreFields' (default null) to allow apps to specify core field classes instead of loading all in specific folder path.

Remaining Tasks:

  • Handle when fields has data responses already submitted before
  • Update Docs

need your feedback on this @atmonshi

Add a new config option 'coreFields' (default null) to allow apps to specify core field classes. Bolt facade now reads zeus-bolt.coreFields: if an array is provided it builds the core field list via Collectors::buildClasses, otherwise it falls back to the package default classes. Also prevent auto-including Bolt Pro fields when custom coreFields are set. Made Collectors::buildClasses public so it can be invoked from the facade. Preserves existing behavior when coreFields is not configured.
@Abdulmajeed-Jamaan
Abdulmajeed-Jamaan marked this pull request as draft February 23, 2026 03:20
@what-the-diff

what-the-diff Bot commented Feb 23, 2026

Copy link
Copy Markdown

PR Summary

  • New Configuration Option Added
    A new configuration setting, known as coreFields, has been introduced in zeus-bolt.php. This option allows you to specify default fields, which are initially set to null.

  • Field Collection Logic Updated
    The system for collecting fields has been refined in Bolt.php. Now, the method verifies if coreFields have been set. If they have, field classes are built based on these coreFields. If not, classes are collected from the default path as before.

  • Conditions for Pro Fields Modified
    Adjustments have been made to the logic inside Bolt.php to incorporate Pro fields only if coreFields are not configured. These changes improve the efficiency under specific configurations.

  • Visibility of a Method Changed
    In Collectors.php, the buildClasses method's visibility has been switched from protected (limited accessibility) to public (wide accessibility). This makes it possible to use this method outside of its original class.

@atmonshi

Copy link
Copy Markdown
Member

i like the idea, clean and direct.
when you ready let me know to test it in the demo app (pro,thunder,etc)

Introduce Bolt::allFields() to aggregate and cache all field definitions (core, app, configured coreFields array, and Bolt Pro fields when available) under the 'bolt.allFields' cache key for 1 month (cleared in local). Merge and sort collected fields by their 'sort' value. Update Filament field select usage in Fields trait: expand closures for readability, add getOptionLabelUsing to resolve labels from allFields(), and adjust formatting/imports. Clarify config comment for 'coreFields' behavior (array to override, null to auto-discover).
Add unit tests for Bolt field discovery and configuration. Tests cover Bolt::allFields and Bolt::availableFields behaviors including auto-discovery, merging configured coreFields, duplicate avoidance, empty arrays, and validation of returned field array keys. Introduces a DummyField test stub implementing FieldsContract to simulate a custom field; tests flush cache and collect auto-discovered classes for assertions.
Adds a new "Core Fields" section to docs/getting-started/configuration.md that documents the coreFields configuration option. Explains that core fields are auto-discovered by default (coreFields => null) and shows how to override discovery by providing an array of specific field class names. Includes examples and notes that custom fields can be included alongside core fields.
@Abdulmajeed-Jamaan
Abdulmajeed-Jamaan marked this pull request as ready for review March 12, 2026 21:27
@Abdulmajeed-Jamaan Abdulmajeed-Jamaan linked an issue Mar 12, 2026 that may be closed by this pull request
@Abdulmajeed-Jamaan

Copy link
Copy Markdown
Contributor Author

Since its only used at filament layer, wouldn't it better to move this config into the plugin registration phase ? , like the following:

->plugins([
    BoltPlugin::make()
        ->formFileds([...])
])

This way will have the following advantages:

Contextual Flexibility: If a user has multiple panels (e.g., Admin and App), they might want different settings for each. A Plugin class allows them to configure each instance uniquely.

Type Safety & IDE Support: Users get immediate autocomplete for our methods.

Dynamic Logic: If the configuration depends on other panel settings or runtime state, the Plugin class is more powerful.

Whats your opinion on this @atmonshi ?

@Abdulmajeed-Jamaan
Abdulmajeed-Jamaan marked this pull request as draft March 20, 2026 05:31
@Abdulmajeed-Jamaan

Copy link
Copy Markdown
Contributor Author

Check #427

@atmonshi

atmonshi commented Jun 5, 2026

Copy link
Copy Markdown
Member

@Abdulmajeed-Jamaan close this in favor of #427 ?

Changes `coreFields` behavior so an array now defines the complete set of available fields (instead of merging with discovered fields), while `null` keeps auto-discovery for Bolt, app, and Pro fields. The field type picker now defaults to the first sorted available field, docs/config comments were updated to clarify cache invalidation (`bolt.fields` and `bolt.allFields`) and ordering rules, and tests were replaced with end-to-end coverage of the new picker/config behavior.
@Abdulmajeed-Jamaan
Abdulmajeed-Jamaan marked this pull request as ready for review August 1, 2026 00:03
@Abdulmajeed-Jamaan

Abdulmajeed-Jamaan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@atmonshi As discussed before in person, will follow this approach instead of #427

Will do the other major versions once this approved.

@Abdulmajeed-Jamaan

Copy link
Copy Markdown
Contributor Author

Handled default field mentioned here as well

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.

Filter available field types

2 participants