-
Notifications
You must be signed in to change notification settings - Fork 388
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
Dynamic Form: add children to override field rendering #1257
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
Thank you for submitting your first issue to this project. |
Thank you @bjdekker for the suggestion! |
Thank you @AJIXuMuK, I try to find some time the coming days to implement this and will create a pul request then |
This looks like it could be used to hide disabled fields. Looking forward to see it in the next version :-) |
@bjdekker I gave it a test and used it to completely hide some fields or alternatively to display them as disabled with a default value that I than add to the data in onBeforeSubmit. Which works fine (had to have a look at the code to see that I have to set newValue to get required fields to work and skip setting values in onBeforeSubmit). Could do with a nice docu and examples ;-) |
Great idea @bjdekker, can't wait to try this out somewhere. |
@IRRDC thanks for checking it out! I will take a look at providing some kind of documentation! |
@AJIXuMuK, Can you please share example for the usage |
Hi @rakeshrelan118 , Basically it can be set up as follows: const fieldOverrides = {
"FieldInternalName1": (fieldProperties: IDynamicFieldProps) => <>some-ui</>,
"FieldInternalName2": (fieldProperties: IDynamicFieldProps) => <>some-ui</>
};
<DynamicForm
listId={someListId}
webAbsoluteUrl={someSiteUrl}
context={spfxContext}
fieldOverrides={fieldOverrides}
/> I believe you can use the |
Category
[x] Enhancement
[ ] Bug
[ ] Question
Version
Please specify what version of the library you are using: [3.8.1]
Expected / Desired Behavior / Question
Currently, the DynamicForm does not allow for overriding individual fields. So you get the form as is. If you want one field to behave differently, you have to write the entire form yourself. I would like to suggest that you can add children to the DynamicForm for the fields that you want to render yourself. Let's say you have a list with three fields: Title, SomeTextField and SomeOtherField and you want to do custom rendering for SomeOtherField, the you could put in a DynamicForm like this:
In the render function of the DynamicForm, you can check in the map whether the children of the component contains a child with the specified internalFieldName, if so, that child (in this case SomeCustomFieldComponent) is rendered, if not, nothing changes and the DynamicField is rendered.
This need to be worked out in more detail, but I'd be happy to check if this can be implemented properly and to submit a pull request for this.
The text was updated successfully, but these errors were encountered: