Skip to content

Commit

Permalink
DynamicForm - disable save button (#1810)
Browse files Browse the repository at this point in the history
* enable/disable save button

* update documentation

---------

Co-authored-by: matteo <>
  • Loading branch information
srpmtt authored Aug 10, 2024
1 parent a1270d0 commit 584b06c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/documentation/docs/controls/DynamicForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The `DynamicForm` can be configured with the following properties:
| webAbsoluteUrl | string | no | Absolute Web Url of target site (user requires permissions). |
| fieldOverrides | {[columnInternalName: string] : {(fieldProperties: IDynamicFieldProps): React.ReactElement\<IDynamicFieldProps\>}} | no | Key value pair for fields you want to override. Key is the internal field name, value is the function to be called for the custom element to render. |
| respectEtag | boolean | no | Specifies if the form should respect the ETag of the item. Default - `true` |
| saveDisabled | boolean | no | Specifies if save button is disabled. |
| validationErrorDialogProps | IValidationErrorDialogProps | no | Specifies validation error dialog properties |
| customIcons | { [ columnInternalName: string ]: string } | no | Specifies custom icons for the form. The key of this dictionary is the column internal name, the value is the Fluent UI icon name. |

Expand Down
4 changes: 2 additions & 2 deletions src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class DynamicForm extends React.Component<
{!this.props.disabled && (
<Stack className={styles.buttons} horizontal tokens={stackTokens}>
<PrimaryButton
disabled={isSaving}
disabled={this.props.saveDisabled || isSaving}
text={strings.Save}
onClick={() => this.onSubmitClick()}
/>
Expand Down Expand Up @@ -418,7 +418,7 @@ export class DynamicForm extends React.Component<
if (field.newValue !== null && field.newValue !== undefined) {

let value = field.newValue;

if (["Lookup", "LookupMulti", "User", "UserMulti", "TaxonomyFieldTypeMulti"].indexOf(fieldType) < 0) {
objects[columnInternalName] = value;
}
Expand Down
4 changes: 4 additions & 0 deletions src/controls/dynamicForm/IDynamicFormProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export interface IDynamicFormProps {
* Specifies if the form is disabled
*/
disabled?: boolean;
/**
* Specify if save button is disabled.
*/
saveDisabled?: boolean;
/**
* List id
*/
Expand Down

0 comments on commit 584b06c

Please sign in to comment.