gcanti / tcomb-form

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

Does t.Dat work properly? #188

Closed joewood closed 9 years ago

joewood commented 9 years ago

Looking at the playground: http://gcanti.github.io/resources/tcomb-form/playground/playground.html When I add a t.Dat field, I only see a textbox? Is this the default behavior?

gcanti commented 9 years ago

tcomb-form v0.3 playground

The playground is outdated, sorry for that

joewood commented 9 years ago

Thanks, I'm seeing the same thing from the current version of tcomb-form in npm: 0.6.3 Do I need to clone and build?

gcanti commented 9 years ago

This is working for me (v0.6.3):

const Foo = t.struct({
  date: t.Date
});

const App = React.createClass({

  onSubmit(evt) {
    evt.preventDefault();
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
    }
  },

  render() {
    return (
      <form onSubmit={this.onSubmit}>
        <t.form.Form
          ref="form"
          type={Foo}
        />
        <button className="btn btn-primary">Save</button>
      </form>
    );
  }

});

I see this:

tcomb-form-date
joewood commented 9 years ago

Funny, I don't see that. Is it t.Date or t.Dat ? I've tried both and neither worked for me. I tried the playground because I thought it may be a bootstrap set-up issue.

gcanti commented 9 years ago

Is it t.Date or t.Dat ?

It's the same, they are aliases.

I've tried both and neither worked for me

Weird...I'm scratching my head, I dont know how to help you out

joewood commented 9 years ago

Could you advise on which bootstrap scripts/CSS files you use? Are there any other dependencies there for the bootstrap templates? Are there any other set-up requirements - or should this work out of the box? Appreciate any help, thanks.

gcanti commented 9 years ago

which bootstrap scripts/CSS files you use

Bootstrap v3.3.1

Are there any other dependencies there for the bootstrap templates

Those declared in the package.json

Are there any other set-up requirements - or should this work out of the box?

It should work out of the box.

Last thing I can try is to put up a new clean project and start from the ground up with the example above, let's see if I'm able to replicate your issue, otherwise it's probably something in your configuration...

joewood commented 9 years ago

That would be great. I'm using bootstrap 3.3.5 from their CDN, but the other dependencies are all in the bundle, built using webpack.

gcanti commented 9 years ago

Last thing I can try is to put up a new clean project and start from the ground up with the example above, let's see if I'm able to replicate your issue

Nope, everything's fine on my side

joewood commented 9 years ago

thanks - any chance you could post that code so I can compare? I tried an empty new project and I'm still seeing the issue.

gcanti commented 9 years ago

Sure, let me put up a temporary repo on GitHub, stay tuned

gcanti commented 9 years ago

Here we are

https://github.com/gcanti/tcomb-form-seed

Let me know how it goes

joewood commented 9 years ago

Thanks, that nailed it. I was using tcomb rather tcomb-form for the data-types. There must be a conflict somewhere. Really appreciate the help!

gcanti commented 9 years ago

Great, happy hacking.

Giulio