pnp / pnp/sp-dev-fx-controls-react

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

Open
#1,862 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:fixed-next-drop type:bug
Dominant language
TypeScript
Stars
433
Forks
418
Avg merge
5d 6m
Merged PRs (30d)
19

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/controls/dynamicForm/DynamicForm.tsx around line 1268, where the DynamicForm fields are assembled. Review how content type fields are selected and verify the existing field.Hidden information. Done means fields hidden at the list content type level no longer appear in the rendered form.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.