Skip to content

Instantly share code, notes, and snippets.

@kevzettler
Created October 30, 2014 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevzettler/c7522e807e00e7cd8721 to your computer and use it in GitHub Desktop.
Save kevzettler/c7522e807e00e7cd8721 to your computer and use it in GitHub Desktop.
meta newforms
/** @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