Created
October 30, 2014 22:08
-
-
Save kevzettler/c7522e807e00e7cd8721 to your computer and use it in GitHub Desktop.
meta newforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
'use strict'; | |
var React = require('react'), | |
Label = require('./Label'), | |
TextField = require('./TextField'); | |
var LabeledInput = React.createClass({ | |
propTypes: { | |
label: React.PropTypes.string.isRequired, | |
name: React.PropTypes.string.isRequired | |
}, | |
render: function() { | |
debugger; | |
return ( | |
<div> | |
<Label htmlFor={this.props.name}> | |
{this.props.label} | |
</Label> | |
<TextField name={this.props.name} | |
placeholder={this.props.placeholder} | |
defaultValue={this.props.defaultValue} /> | |
</div>); | |
} | |
}); | |
module.exports = LabeledInput; | |
/** @jsx React.DOM */ | |
'use strict'; | |
var React = require('react'), | |
newforms = require('newforms'); | |
var Form = { | |
//...bunch of other pre-existing input types here | |
LabeledInput: require('./form/LabeledInput') | |
}; | |
Object.keys(Form).forEach(function(key){ | |
Form["NF"+key] = newforms.Input.extend({ | |
render: function(name, value, kwargs){ | |
return Form[key](this.attrs); | |
} | |
}); | |
}); | |
module.exports = Form; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment