gcanti / tcomb-form

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

How to set field labels of a list? #146

Closed angelocala94 closed 9 years ago

angelocala94 commented 9 years ago

I have this:

var Test = t.struct({
      field1: t.Str,
      field2: t.Str
});

var TestList = t.struct({
      list: t.list(Test)
});

How can i set the fields label for field1 and field2?

gcanti commented 9 years ago

You have two nested structs so:

var options = {
  fields: { // TestList is a struct..
    list: { // ..with a "list" field..
      item: { // ..which is a list of..
        fields: { // ..Test structs
          field1: {
            label: 'label field1'
          },
          field2: {
            label: 'label field2'
          }
        }
      }
    }
  }
};
angelocala94 commented 9 years ago

Thanks.