Last active
February 26, 2018 08:18
-
-
Save zeusbaba/c08ba245b457c245640f45df486d3fa5 to your computer and use it in GitHub Desktop.
admin-on-rest using material-ui-datetimepicker as custom input component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import DateTimePicker from 'material-ui-datetimepicker'; | |
import DatePickerDialog from 'material-ui/DatePicker/DatePickerDialog' | |
import TimePickerDialog from 'material-ui/TimePicker/TimePickerDialog'; | |
import { Field } from 'redux-form'; | |
const renderMyDateTimeInput = ({ input, meta: { touched, error } }) => ( | |
// for more customisation, see https://github.com/dmtrKovalenko/material-ui-datetimepicker | |
<DateTimePicker | |
DatePicker={DatePickerDialog} | |
TimePicker={TimePickerDialog} | |
errorText={touched && error} | |
{...input} | |
/> | |
); | |
const MyDateTimeInput = ({ source }) => <Field name={source} component={renderMyDateTimeInput} /> | |
export default MyDateTimeInput; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
then you can use it inside admin-on-rest SimpleForm like this below;
more docs/info at admin-on-rest