Skip to content

Instantly share code, notes, and snippets.

@mzabriskie
Last active June 14, 2016 22:19
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 mzabriskie/c58d5210beb0894189ab0fbcbd5dbf73 to your computer and use it in GitHub Desktop.
Save mzabriskie/c58d5210beb0894189ab0fbcbd5dbf73 to your computer and use it in GitHub Desktop.

Example use of <FormField/>:

<FormField label="Username" errors={['Cannot be left blank']}>
  <input type="text" name="username" value=""/>
</FormField>

This renders something like:

<div class="hasError">
  <label>Username</label>
  <input type="text" value=""/>
  <ul class="errors">
    <li>Cannot be left blank</li>
  </ul>
</div>

<FormField/> simply renders props.children so any type of input (custom or native) can be used:

<FormField label="State">
  <select name="state">
  {states.map(s => <option value={s.value}>{s.label}</option>)}
  </select>
</FormField>

<FormField label="Entry Date">
  <DatePicker name="entryDate" value={Date.now()}/>
</FormField>

<FormField label="Favorite Color">
  <ColorPicker/>
</FormField>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment