aakk
aakk

Reputation: 21

Error in Material UI DatePicker does not invalidate the Field/Form

The DatePicker is in a wrapper component and although the error message is displaying correctly but it isn't invalidate the field or form if the date is set as incorrect. I know about the onError callback function but I don't know what to call here. The validation is not occuring on onSubmit hence can't use the SubmissionError or submitfailed.

I can pass an external validator from form field but I just leave it as a last option.

Date Picker

 <InlineDatePicker
      format={DATE_FORMAT_UI}
      keyboard
      mask={mask}
      maxDate={maxDate}
      minDate={minDate}
      placeholder={DATE_FORMAT_UI}
      value={formattedStoreValue}
      variant="outlined"
      onBlur={this.handleBlur}
      onChange={this.handleChange}
      **onError={(_,error)=>{ don't know what to do here })}**
      {...other}
    />

Form Field

             <Field
                name={someDate}
                component={InlineDatePickerField}
                **validate={[required]} //If not possible then add another validator here as last option**
                id={someDate}
                label="To"
                minDate={this.minDate()}
                required
                className="w-full"
              />

Upvotes: 2

Views: 1245

Answers (0)

Related Questions