Open TurtleWolfe opened 6 years ago
after trying to formulate my question for stack overflow, the top 'pre-suggested' answer suggests a conflict in the html5 date picker, that might be eased with jquery's date picker UI. The tutorial originally suggested loading jquery anyways & I remember a comment asking if it wouldn't conflict with React. I'm hoping just using the date picker will help. The original tutorial did not cover displaying a date to be edited.. https://stackoverflow.com/questions/30798906/the-specified-value-does-not-conform-to-the-required-format-yyyy-mm-dd
The specified value "2018-04-01T00:00:00.000Z" does not conform to the required format, "yyyy-MM-dd"
I found where to format the date for Materialize in the initiation options, but now my date picker disappears.
<script>
$(document).ready(() => {
$(".button-collapse").sideNav();
$('.datepicker').datepicker('yyyy-MM-dd');
});
</script>
.. since they both call className .datepicker, I wonder if Materialize & JQuery are causing a conflict
<div className = "input-field" >
<input type="date" class="datepicker" date = {this.state.date_planted} name = "date_planted" ref = "date_planted" value = {this.state.date_planted} onChange = {this.handleInputChange} />
<label htmlFor = "date_planted" ></label>
</div>
<div className = "input-field" >
<input type="text" className="datepicker" date = {this.state.date_last_checked} name = "date_last_checked" ref = "date_last_checked" value = {this.state.date_last_checked} onChange = {this.handleInputChange} />
<label htmlFor = "date_last_checked" ></label>
</div>
If I change input type to text, it prefills with the correct date, but my datepicker is unavailable. If I leave the input type as date, then it prefills to "mm/dd/yyyy" like it has no info to reference.
https://github.com/TurtleWolf/Food_Liberation_Front
https://food-liberation-front.herokuapp.com
reformulating my question.. or maybe a new one. It's actually giving me the date picker, as long as I reload the page. I think it's a classic case of the page ready firing before the SPA is finished loading
The specified value "2018-04-01T00:00:00.000Z" does not conform to the required format, "yyyy-MM-dd"
When I 'prefill' the dates, I need to change the format of the date. Not sure where to hook this in at. I'm sure I need a function to reformat it, but I'm not sure where to place it at.. I know it's getting the date object from MongoDB.. I can 'input' it in the 'preferred' format & it'll still change when it's saved in MongoDB. I do not know if this date picker is coming from JQuery or HTML5 or if that would even affect it.
https://github.com/TurtleWolf/Food_Liberation_Front
https://food-liberation-front.herokuapp.com