sp-dev-fx-controls-react icon indicating copy to clipboard operation
sp-dev-fx-controls-react copied to clipboard

DynamicForm - Form should hide fields that are hidden on the list content type

Open martinlingstuyl opened this issue 1 year ago • 0 comments

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version 3.18.1

Expected / Desired Behavior / Question

If I'm rendering a form on a library with content types, and some fields are hidden at list content type level, those fields should not show up in the rendered dynamic form.

Observed Behavior

Fields that are hidden at content type level currently show up in the rendered form, I now have to work around that manually by adding these fields to the hiddenFields option, which is a shame, because I need to add quite some custom code to make that work.

Steps to Reproduce

Create a list content type with a couple of hidden fields, and render a DynamicForm, using the content type id:

public render(): React.ReactElement<{}> {
    return <>
      <DynamicForm 
        context={(this.props.context as any)} 
        listId={this.props.context.list.guid.toString()}
        listItemId={this.props.context.itemId}
        contentTypeId={this.props.context.contentType.id}      
      />
    </>;

The solution should probably be implemented in the following location. It would be easy to filter out fields based on field.Hidden.
https://github.com/pnp/sp-dev-fx-controls-react/blob/bf61b7a35b7ee98e595bbd0d6b614a0bf71b724f/src/controls/dynamicForm/DynamicForm.tsx#L1268

martinlingstuyl avatar Aug 14 '24 11:08 martinlingstuyl