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

DynamicForm - disable save button #1810

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
michaelmaillot marked this conversation as resolved.
Show resolved Hide resolved
/**
* List id
*/
Expand Down