Skip to content

Commit 6688962

Browse files
author
Emmanouil Konstantinidis
committed
Required Inputs
1 parent 6bbb4a1 commit 6688962

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

rest_framework_docs/static/rest_framework_docs/js/components/helpers/input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ var Input = React.createClass({
2121
id={this.props.name}
2222
placeholder={this.props.placeholder}
2323
onChange={this.handleChange}
24-
value={this.props.value} />
24+
value={this.props.value}
25+
required={this.props.required} />
2526
</div>
2627
</div>
2728
);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ var FieldsData = React.createClass({
1212
return this.props.fields.map(function (field, key) {
1313
var value = this.props.data[field.name];
1414
var type = field.name == 'password' ? 'password' : 'text';
15+
1516
return (
1617
<Input
1718
key={key}
1819
type={type}
1920
name={field.name}
2021
value={value}
2122
placeholder={field.type}
22-
required={field.required}
23+
required={field.required ? 'required' : false}
2324
onChange={this.handleChange.bind(this, field.name)} />
2425
);
2526
}, this);

rest_framework_docs/static/rest_framework_docs/js/dist.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32364,7 +32364,8 @@ var Input = React.createClass({
3236432364
id: this.props.name,
3236532365
placeholder: this.props.placeholder,
3236632366
onChange: this.handleChange,
32367-
value: this.props.value })
32367+
value: this.props.value,
32368+
required: this.props.required })
3236832369
)
3236932370
);
3237032371
}
@@ -32626,13 +32627,14 @@ var FieldsData = React.createClass({
3262632627
return this.props.fields.map(function (field, key) {
3262732628
var value = this.props.data[field.name];
3262832629
var type = field.name == 'password' ? 'password' : 'text';
32630+
3262932631
return React.createElement(Input, {
3263032632
key: key,
3263132633
type: type,
3263232634
name: field.name,
3263332635
value: value,
3263432636
placeholder: field.type,
32635-
required: field.required,
32637+
required: field.required ? 'required' : false,
3263632638
onChange: this.handleChange.bind(this, field.name) });
3263732639
}, this);
3263832640
},

0 commit comments

Comments
 (0)