Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactivity 2.0 #1500

Merged
merged 11 commits into from
Jan 26, 2025
Merged

Reactivity 2.0 #1500

merged 11 commits into from
Jan 26, 2025

Conversation

lee-to
Copy link
Collaborator

@lee-to lee-to commented Jan 25, 2025

Almost all fields support reactivity except:

  • Json is not in object mode
  • BelongsToMany with AsyncSearch
  • RelationRepeater
  • HasMany/HasOne/MorphTo

Also in custom fields it is now possible to configure reactivity support, turn it off or specify how exactly to prepare and receive values:

public function isReactivitySupported(): bool;

public function prepareReactivityValue(mixed $value, mixed &$casted, array &$except): mixed;

public function getReactiveValue(): mixed;

Reactive Template example:

Template::make("Template")->fields([
    Text::make('Title'),
])->changeFill(fn($data, Template $ctx) => data_get($data, 'template'))->changeRender(
    fn($value, Template $ctx) => new FieldContainer(
        field: $ctx,
        slot: FieldsGroup::make($ctx->getPreparedFields())->render(),
    ),
)->reactive(),

@lee-to lee-to added this to the 3.4.0 milestone Jan 25, 2025
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