gcanti / tcomb-json-schema

Transforms a JSON Schema to a tcomb type
MIT License
144 stars 32 forks source link

Boolean rendering as text input rather than checkbox #22

Closed rnewstead1 closed 8 years ago

rnewstead1 commented 8 years ago

I am using:

I am using the boolean example from the tcomb-json-schema playground to render a checkbox.

However the boolean gets rendered as a text input rather than a checkbox.

Code:

import React, {Component, PropTypes} from 'react';
import t from 'tcomb-form';
import transform from 'tcomb-json-schema';

const Form = t.form.Form;

const json = {
  "type": "object",
  "properties": {
    "username": {
      "type": "string"
    },
    "rememberMe": {
      "type": "boolean"
    }
  },
  "required": ["username"]
};

const schema = transform(json);

class MyForm extends Component {

  render() {
    return (
      <form>
        <Form ref="form" type={schema}/>
      </form>
    );
  }
}

export default MyForm;

Screenshot:

boolean-rendered-as-text-input

From debugging, it looks like transform is correctly identifying the boolean, but I can't work out why this is not getting rendered.

Is there some incompatibility between the versions I'm using? I noticed the playground is using an older version of tcomb-json-schema.

gcanti commented 8 years ago

Hi @rnewstead1, may be relevant https://github.com/gcanti/tcomb-form/issues/303#issuecomment-189698990

rnewstead1 commented 8 years ago

Thanks @gcanti. It looks like tcomb 2.7.0 is included from the templates. I've raised a PR to update this: https://github.com/gcanti/tcomb-form-templates-bootstrap/pull/6.

I'll let you know if this fixed the issue.

gcanti commented 8 years ago

Oh wow, you are right. Sorry for the inconvenience

gcanti commented 8 years ago

@rnewstead1 just published:

https://github.com/gcanti/tcomb-form-templates-bootstrap/releases/tag/v0.2.0 https://github.com/gcanti/tcomb-form/releases/tag/v0.9.1

should fix this issue

rnewstead1 commented 8 years ago

Fixed! Thanks @gcanti

gcanti commented 8 years ago

Thanks to you for reporting