Skip to content

Commit 777e27e

Browse files
19 - Preset Input Value
1 parent 1cfb591 commit 777e27e

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/reactify-ui/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/reactify-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6+
"moment": "^2.22.2",
67
"react": "^16.4.0",
78
"react-cookies": "^0.1.0",
89
"react-dom": "^16.4.0",

src/reactify-ui/src/posts/PostCreate.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component} from 'react'
22
import 'whatwg-fetch'
33
import cookie from 'react-cookies'
4+
import moment from 'moment'
45

56
class PostCreate extends Component {
67
constructor(props){
@@ -97,12 +98,13 @@ class PostCreate extends Component {
9798
draft: false,
9899
title: null,
99100
content: null,
100-
publish: null,
101+
publish: moment(new Date()).format('YYYY-MM-DD'),
101102
})
102103
this.postTitleRef.current.focus()
103104
}
104105

105106
render(){
107+
const {publish} = this.state
106108
return (
107109
<form onSubmit={this.handleSubmit} ref={(el) => this.postCreateForm = el}>
108110
<div className='form-group'>
@@ -129,7 +131,14 @@ class PostCreate extends Component {
129131
</div>
130132
<div className='form-group'>
131133
<label for='publish'>Publish Date</label>
132-
<input type='date' id='publish' name='publish' className='form-control' onChange={this.handleInputChange} required='required'/>
134+
<input
135+
type='date'
136+
id='publish'
137+
name='publish'
138+
className='form-control'
139+
onChange={this.handleInputChange}
140+
value={publish}
141+
required='required'/>
133142
</div>
134143
<button className='btn btn-primary'>Save</button>
135144
<button className='btn btn-secondary' onClick={this.clearForm}>Cancel</button>

src/staticfiles/js/reactify-django.ui.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)