Aby
Aby

Reputation: 11

Material UI TextField with type datetime-local date picker with seconds

I am using react-admin and want to edit date and time including seconds using DateTimeInput. However, I am not able to do that. I tried following:

Option 1:

<TextField
  id={id}
  {...input}
  step='1'
  value={format(input.value) || ''}
  variant={variant}
  error={!!(touched && (error || submitError))}
  helperText={<InputHelperText touched={touched ?? false} error={error || submitError} helperText={helperText} />}
  label={<FieldTitle label={label} source={source} resource={resource} isRequired={isRequired} />}
  {...options}
  {...sanitizeInputRestProps(rest)}
/>

Option 2:

<DateTimeInput label='Scratched Time' source='scratched_time' disabled={!scratched} />

But, I am not able to edit the seconds field.

Upvotes: 0

Views: 4751

Answers (1)

Try to put "step" inside "inputProps" instead. ;-)

<TextField 
    inputProps={{
        "step": 1,
    }}
    type="datetime-local"
/>

Example

Upvotes: 1

Related Questions