Created
February 3, 2016 12:30
-
-
Save zindel/e1a429ba4eca54fffd9a to your computer and use it in GitHub Desktop.
This file contains 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
import React from 'react'; | |
import {Preloader} from 'rex-widget/ui'; | |
import {Fetch} from 'rex-widget/data'; | |
import * as forms from 'rex-widget/form'; | |
@Fetch(function fetchGreeting(propsAndDataParams) { | |
let {data, id} = propsAndDataParams; | |
return { | |
data: data.params({'user:id': id}).getSingleEntity(), | |
} | |
}) | |
export default class SimpleForm extends React.Component { | |
render() { | |
let {data} = this.props.fetched; | |
// uses JSON schema. See http://json-schema.org/ | |
let schema = { | |
type: 'object', | |
required: ['name'], | |
properties: { | |
name: {type: 'string'}, | |
is_expired: {type: 'boolean'} | |
} | |
}; | |
return ( | |
<div> | |
{data.updating ? <Preloader/> : | |
<form.EntityForm | |
entity="user" | |
schema="schema" | |
value={data} | |
submitTo={this.props.data} | |
> | |
Name: <form.Field selectFormValue="name"/> | |
Expired?: <form.CheckboxField selectFormValue="is_expired"/> | |
</form.EntityForm> | |
} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment