How to type a label on a tcomb form on React Native?

261 views Asked by At

I have this code and I want to choose the label of each section, because they are automatically generated with the code. If i choose the "WineName" to "Wine Name" nothing happens.

var type = t.enums({
   type1: 'Red',
   type2: 'Rosé',
   type3: 'White'
});    
var FichaUm = t.struct({
    WineName: t.String,
    harvest: harvest,
    type: type,
    producername: t.String,
    country: country,
    zone: t.String
});
2

There are 2 answers

0
Pedro Martins On

You should be able to create an options object and pass it to the form, it would be something like this:

let options = {
  fields: {
    "sectionName": {
      label: "your label"
    }
  }
}

and then on the form element

<Form type={FichaUm} options={options}/> 
2
Prasun On

To use object property with spaces, you can use Bracket notation to set object property. Consider following snippets

var FichaUm = t.struct({
 ['Wine Name']: t.String,
 harvest: harvest,
 type: type,
 producername: t.String,
 country: country,
 zone: t.String
});

Hope this will help!