Skip to content

[Bug][DynamicForm] OnBeforeSubmit does not fire when using a mandatory field in the FieldOverrides #1950

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

Open
Benatiabacemdev opened this issue Feb 11, 2025 · 4 comments

Comments

@Benatiabacemdev
Copy link

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

Please specify what version of the library you are using: [3.20.0]

Expected / Desired Behavior / Question

In DynamicForm, when I use fieldoverrides with a required field, onBeforeSubmit does not fire and the form is not submitted. By default the field was red (error) and when I type something it turns black and without an error message, but when I click submit nothing happens. if I update the list field as non-required, the dynamic form works fine.

Observed Behavior

In DynamicForm, when I use fieldoverrides with a required field, onBeforeSubmit does not fire and the form is not submitted.

Steps to Reproduce

By default the field was red (error) and when I type something it turns black and without an error message, but when I click submit nothing happens. if I update the list field as non-required, the dynamic form works fine.

Thanks!

Copy link

Thank you for submitting your first issue to this project.

@BlazeOfFeathers
Copy link

Same issue here!

@martinlingstuyl
Copy link
Contributor

Same here. The problem seems to be that for fieldOverrides, the forms field-onChange handler is not triggered, leading to the fields newValue not being set in the DynamicForm.

This did work correctly in version 3.15.0 though...

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Apr 8, 2025

Ok, so the point is you need to let the DynamicForm know that a field has changed.

So if your override contains a TextField control for example, you'll need to implement an event handler, like onChange or onBlur. In the event you call the onChanged function in the fieldProperties, like so:

private renderField = (
    fieldProperties: IDynamicFieldProps
  ): React.ReactElement<IDynamicFieldProps> => {
    return (
      <>
        <div className={styles.fieldWrapper}>
          <TextField
            label={strings.SiteName}
            defaultValue={fieldProperties.value}
            onChange={(ev, newValue) =>
              fieldProperties.onChanged(fieldProperties.columnInternalName, newValue, true);
            }
            required={fieldProperties.required}
            disabled={fieldProperties.disabled}
            placeholder={fieldProperties.placeholder}
            autoComplete="off"
          />
          <text className={styles.fieldDescription}>
            {fieldProperties.description}
          </text>
        </div>
      </>
    );
  };

in version 3.15.0 you could use fieldValues.newValue = newValue in the event. But now you need to call the onChanged function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants