gcanti / tcomb-form

Forms library for react
https://gcanti.github.io/tcomb-form
MIT License
1.16k stars 136 forks source link

How to reuse a default field in a custom template? #224

Closed volkanunsal closed 8 years ago

volkanunsal commented 8 years ago

How can I render the default implementation of the Select field in tcomb-form when I am implementing a custom template for a field?

My implementation only needs to wrap the form field, and I don't want to reinvent the wheel to do this:

var myLayout = function(locals){
  var defaultSelect = ???
  return (
    <div className='panel panel-filter'>
      <div className='panel-heading'>
        <b className='panel-title'>{locals.label}</b>
      </div>
      <ul className='list-group'>
           {defaultSelect}
      </ul>
    </div>
  );
};

export let options = {
  fields: {
    status: {
      label: 'Status',
      template: myLayout
    }
 }

I have tried the following solution, but it does not work:

import { compile } from 'uvdom/react';
compile(t.form.Form.templates.select(locals))

Edit:

Btw, these are the versions I'm using:

"tcomb": "2.2.0",
"tcomb-form": "0.6.3",
"uvdom": "0.1.2"
volkanunsal commented 8 years ago

Whoops. It does work. I think my versions were out of sync.