Skip to content

Commit 2fa1cc2

Browse files
author
Emmanouil Konstantinidis
committed
Prevent extra fields without name
1 parent d467763 commit 2fa1cc2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

rest_framework_docs/static/rest_framework_docs/js/components/request/add-fields.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ var AddFieldsForm = React.createClass({
1111
},
1212

1313
addField: function () {
14-
this.props.onAdd(this.state.fieldName);
15-
this.setState({
16-
fieldName: ''
17-
});
14+
if (this.state.fieldName) {
15+
this.props.onAdd(this.state.fieldName);
16+
this.setState({
17+
fieldName: ''
18+
});
19+
}
1820
},
1921

2022
handleKeyPress: function (event) {
@@ -36,12 +38,12 @@ var AddFieldsForm = React.createClass({
3638
<Header title='Add Extra Fields' />
3739

3840
<div className='form-group'>
39-
<label className='col-sm-4 control-label'>Add Field</label>
41+
<label className='col-sm-4 control-label'>Field Name</label>
4042
<div className="col-sm-6">
4143
<input
4244
type='text'
4345
className='form-control input-sm'
44-
placeholder='Field Name (ie. email_address)'
46+
placeholder='ie. email_address'
4547
onKeyPress = {this.handleKeyPress}
4648
onChange={this.handleChange}
4749
value={this.state.fieldName} />

0 commit comments

Comments
 (0)