0

Is there any attribute we can use to disable future dates in react admin Date Input filter.

<DateInput
source="name"
label="name"
alwaysOn
validate={getValidate(props)}
/>
krypton
  • 61
  • 2
  • 7

2 Answers2

3

React-admin uses html5 date input under the hood, so you can use the min and max attributes for that. See Restrict future dates in HTML5 date input.

  • I applied max attribute in DateInput, while rendering it's getting applied in div instead of the input tag – krypton May 25 '21 at 18:30
  • My mistake, you have to use the inputProps props to pass the props directly to the input. react-admin DateInput uses material-ui TextField see https://material-ui.com/api/text-field/ and https://stackoverflow.com/questions/63379460/how-can-i-set-min-attribute-for-a-textfield-type-date-in-material-ui – Thiery Michel May 26 '21 at 07:25
0

we can pass as prop the property inputProps and send min and max

 <DateTimeInput
   source="end_time"
   label="end_time"
   fullWidth
   inputProps={{
     min: '2022-04-22T00:00',
     max: '2022-04-28T00:00',
    }}
 />
Felipe Corredor
  • 549
  • 4
  • 9