universe:ui-react-forms

v0.1.3Published 8 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

universe:ui-react-forms

Basic usage

1export const Collection = new UniCollection('collection');
2
3Collection.setSchema({
4    'field1': {
5        type: String,
6        uniUI: {
7            component: 'text'  // explicit; component is deduced from type
8            componentProps: {} // extra component props,
9
10            // Extra options to specific modes
11            view: {label: '', className: ''},
12            edit: {label: '', className: '', placeholder: ''}
13        }
14    },
15
16    'field2': {
17        type: Object
18    },
19
20    'field2.subField': {
21        type: Number
22    }
23});
1import {UniUI} from '{universe:ui-react-forms}';
2import {DualLinkMixin} from '{universe:utilities-react}';
3
4import Collection from 'Collection';
5
6export const CollectionForm = React.createClass({
7    displayName: 'CollectionForm',
8
9    mixins: [DualLinkMixin],
10
11    componentWillMount () {
12        this.dualLink().setRemote(this.props.doc);
13    },
14
15    componentWillReceiveProps (props) {
16        this.dualLink().clear();
17        this.dualLink().setRemote(props.doc);
18    },
19
20    render () {
21        return UniUI.render(this.dualLink(), (doc, done) => {
22            console.log('onSubmit', doc);
23            done();
24        }, 'edit');
25    }
26});