Skip to content

Add support for dynamic field values - #401

Merged
giuscris merged 4 commits into
2.xfrom
feature/dynamic-field-values
Jul 2, 2023
Merged

Add support for dynamic field values#401
giuscris merged 4 commits into
2.xfrom
feature/dynamic-field-values

Conversation

@giuscris

Copy link
Copy Markdown
Member

This PR adds the possibility to use dynamic field values.
This feature supersedes the import key, used to call static functions.

From now, field keys ending with @ introduce dynamic values, which are lazily computed when accessed. Values are parsed with dot notation, i.e. formwork.site().currentPage().title() corresponds to $formwork->site()->currentPage()->title().

This syntax is more streamlined, so for example this syntax:

role:
    type: select
    label: '{{panel.user.role}}'
    disabled: true
    import:
        options: 'Formwork\Panel\Users\UserCollection::availableRoles'

Becomes:

role:
    type: select
    label: '{{panel.user.role}}'
    disabled: true
    options@: formwork.panel().users().availableRoles()

In the future the possibility to parse expressions could be added.

@giuscris giuscris added the enhancement New feature or request label Dec 11, 2022
@giuscris giuscris added this to the 2.0.0 milestone Dec 11, 2022
@giuscris giuscris self-assigned this Dec 11, 2022
@giuscris
giuscris merged commit c9f720d into 2.x Jul 2, 2023
@giuscris
giuscris deleted the feature/dynamic-field-values branch July 2, 2023 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant