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

An extra event: onListItemLoaded could be useful with Dynamic Forms #1472

Closed
martinlingstuyl opened this issue Feb 27, 2023 · 4 comments
Closed
Assignees
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.

Comments

@martinlingstuyl
Copy link
Contributor

Category

[x] Enhancement
[ ] Bug
[ ] Question

Version

3.11 (Because 3.12 has an issue on dynamicforms)

Expected / Desired Behavior / Question

I'm using Dynamic Forms in combination with fieldOverrides to create custom field experiences. The current setup works when using it in normal situations: you have a simple field and override it, and update the value in the form.
But if you have multiple fields that have to interact with each other, you need the state of the containing component to build it up.
In this situation it becomes necessary (eg when using an edit form) to have a moment when you can fill that state with the values of the listitem.
To do this an extra event is necessary: onListItemLoaded. something like this:

const fieldOverrides: {[key: string]: any} = {
      "SomeFieldX": (fieldProperties: IDynamicFieldProps) => this.renderSomeFieldX(fieldProperties),
      "SomeFieldY": (fieldProperties: IDynamicFieldProps) => this.renderSomeFieldY(fieldProperties)
};

return <>
<DynamicForm 
    context={this.props.context as any} 
    listId={this.props.context.list.guid.toString()}    
    listItemId={this.props.context.itemId}     
    onListItemloaded={(listItemDate: any)=> { /* do something to update the state */}
    onBeforeSubmit={this._onBeforeSubmit}
    fieldOverrides={fieldOverrides} 
/></>;
@ghost
Copy link

ghost commented Feb 27, 2023

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Feb 27, 2023
@github-actions
Copy link

Thank you for submitting your first issue to this project.

@joelfmrodrigues
Copy link
Collaborator

@martinlingstuyl definitely makes sense. Would you be available to help and submit a PR?

@joelfmrodrigues joelfmrodrigues added type:enhancement New feature or enhancement of existing capability help wanted and removed Needs: Triage 🔍 labels Mar 1, 2023
@martinlingstuyl
Copy link
Contributor Author

Sure @joelfmrodrigues, I can look into it. You can assign me. I'll probably not get it done in the coming 2 weeks, but I will get to it.

joaojmendes added a commit that referenced this issue Mar 5, 2023
…oaded

Adds onListItemLoaded handler to DynamicForm. Closes #1472
@joaojmendes joaojmendes added status:fixed-next-drop Issue will be fixed in upcoming release. and removed help wanted type:enhancement New feature or enhancement of existing capability labels Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

No branches or pull requests

3 participants