1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Ensure unique ids in feature form. Closes #57.

This commit is contained in:
Jari Bakken 2014-12-03 14:19:28 +01:00 committed by Ivar Conradi Østhus
parent 0e01c89260
commit 0047d52ef4
2 changed files with 9 additions and 7 deletions

View File

@ -59,6 +59,8 @@ var FeatureForm = React.createClass({
enabled: false enabled: false
}; };
var idPrefix = this.props.feature ? this.props.feature.name : 'new';
return ( return (
<div className="bg-lilac-xlt r-pam"> <div className="bg-lilac-xlt r-pam">
<form ref="form" className="r-size1of2"> <form ref="form" className="r-size1of2">
@ -67,7 +69,7 @@ var FeatureForm = React.createClass({
{this.props.feature ? "" : <legend>Create new toggle</legend>} {this.props.feature ? "" : <legend>Create new toggle</legend>}
<TextInput <TextInput
id="name" id={idPrefix + "-name"}
name="name" name="name"
label="Name" label="Name"
value={feature.name} value={feature.name}
@ -76,7 +78,7 @@ var FeatureForm = React.createClass({
placeholder="Toggle name" /> placeholder="Toggle name" />
<TextInput <TextInput
id="description" id={idPrefix + "-description"}
name="description" name="description"
label="Description" label="Description"
value={feature.description} value={feature.description}
@ -84,9 +86,9 @@ var FeatureForm = React.createClass({
placeholder="Enter description" /> placeholder="Enter description" />
<div className="formelement"> <div className="formelement">
<label htmlFor="strategy">Strategy</label> <label htmlFor={idPrefix + "-strategy"}>Strategy</label>
<div className="input select"> <div className="input select">
<select id="strategy" ref="strategy" value={this.state.currentStrategy} onChange={this.onStrategyChange}> <select id={idPrefix + "-strategy"} ref="strategy" value={this.state.currentStrategy} onChange={this.onStrategyChange}>
{this.renderStrategyOptions()} {this.renderStrategyOptions()}
</select> </select>
</div> </div>
@ -96,8 +98,8 @@ var FeatureForm = React.createClass({
<div className="input"> <div className="input">
<ul className="inputs-list"> <ul className="inputs-list">
<li> <li>
<input id="active" ref="enabled" type="checkbox" defaultChecked={feature.enabled} /> <input id={idPrefix + "-active"} ref="enabled" type="checkbox" defaultChecked={feature.enabled} />
<label htmlFor="active">Active</label> <label htmlFor={idPrefix + "-active"}>Active</label>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -28,7 +28,7 @@ var TextInput = React.createClass({
render: function() { render: function() {
return ( return (
<div className="formelement required"> <div className="formelement required">
<label htmlFor="strategy_name" className="t4">{this.props.label}</label> <label htmlFor={this.props.id} className="t4">{this.props.label}</label>
<div className="input"> <div className="input">
<input type="text" <input type="text"
id={this.props.id} id={this.props.id}