Skip to content

Commit

Permalink
Render enums as radio boxes instead of select boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Feb 7, 2016
1 parent 9e825ab commit 451728c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/js/components/base/Wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,28 +339,25 @@ class Wizard extends React.Component {
value={value}/>
);
} else if (input.type === "enum") {
formElement = input.values.map((item) => {
formElement = input.values.map((item, i) => {
return (
<option value={item.value}>
{item.text}
</option>
<label className="radio-option">
<input key={name} name={name} type="radio" value={item.value}
checked={i === 0 && !value || value === item.value}
onChange={this._onFormChange.bind(this)}/>
<span>{item.text}</span>
</label>
);
});

formElement = (
<select key={name} name={name} value={value} onChange={this._onFormChange.bind(this)}
size="1">
{formElement}
</select>
);
} else if (input.type === "hidden") {
return (
<input type="hidden" name={name} value={input.value}/>
);
} else if (input.type === "boolean") {
formElement = (
<label>
<input type="checkbox" name={name} checked={value} onChange={this._onFormChange.bind(this)} value="1"/>
<input type="checkbox" name={name} checked={value} onChange={this._onFormChange.bind(this)}
value="1"/>
{value ? (input.active || "active") : (input.inactive || "inactive")}
</label>
);
Expand Down
15 changes: 15 additions & 0 deletions src/sass/_wizard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,19 @@
.restriction label {
display: inline-block;
margin: 8px;
}

.radio-option {
padding: 4px;
display: block;
}

.radio-option input[type="radio"] {
margin: 4px 8px;
float: left;
}

.radio-option > span {
padding-left: 30px;
display: block;
}

0 comments on commit 451728c

Please sign in to comment.