jquense / react-widgets

Polished, feature rich, accessible form inputs built with React
http://jquense.github.io/react-widgets/
MIT License
2.34k stars 395 forks source link

DateTimePicker is not handling required attribute #383

Closed lik2016 closed 8 years ago

lik2016 commented 8 years ago

I am having a need to make some date pickers as a required field in a form, but the required attribute is not handled.

<DateTimePicker defaultVaule={null} required="required" footer={false} format="MM/DD/YYYY" time={false} onChange={this._onDateChange.bind(this, 'invoice')} />

jquense commented 8 years ago

Hi there, that is correct, the widgets don't support native form validation, because not all of the widgets even have inputs that can be validated (dropdown, multiselect, etc). In general native validation with react is just going to be a bad time, my suggestion is to use a form library like react-formal, or redux-form (if you are using redux) which handle all the concerns, edge cases, and complexity of form validation

lik2016 commented 8 years ago

Adding just one-line of code in DateTimePicker.js will make your widget have this feature. Add the following in _react2.default.createElement (after line 306). required: _props.required, Would you mind making this change?

jquense commented 8 years ago

I don't want to make the change because then the widget suite would inconsistently sort-of support this. Since its not possible to have good or even "ok" support for native form validation for the inputs I'd rather not pretend that its supported, instead it makes more sense to use a proper form validation library.

lik2016 commented 8 years ago

understood. I have another question unrelated to this issue. .babelrc has preset "jason". I am getting errors with this preset? Would you change to like 'es2015'? Thanks.

jquense commented 8 years ago

the babel preset is just a personal collection of presets, it essentailly es2015. it shouldn't throw errors as its related to the build process, it shouldn't effect you consumption of the library. if so then its a problem lower down with one of the packages, try uninstalling and reinstalling