gcanti / tcomb-form

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

No checkboxes for Boolean #401

Open klooperator opened 6 years ago

klooperator commented 6 years ago

Version

Tell us which versions you are using:

Expected behaviour

Form should return a checkbox ( or a template for it) for a tcomb type Boolean.

Actual behaviour

Form returns a Textbox

Hi,

we are using tcomb-validation in one project to pass struct, option and values to another project that then renders that with tcomb-form. Everything is ok for lists and text, but with Booleans it return textbox ( never invoking checkbox template).

I had inspected the code from tcom-form and in this part:

` switch (type.meta.kind) {

  case 'irreducible':

    if (type === _tcombValidation2['default'].Boolean) {

      return Checkbox; // eslint-disable-line no-use-before-define

    } else if (type === _tcombValidation2['default'].Date) {

        return Datetime; // eslint-disable-line no-use-before-define

      }

    return Textbox; // eslint-disable-line no-use-before-define

  case 'struct':

  case 'interface':

... `

It always return checkbox, even thought type.meta.name is Boolean...

Any suggestions?

gcanti commented 6 years ago

First suggestion is: make sure you haven't 2 copies of tcomb in your node_modules

https://github.com/gcanti/tcomb-form/issues/295#issuecomment-180426206

klooperator commented 6 years ago

Hi, no, no 2 copies of tcomb in any project...