Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

password field no longer hides input #39

Closed
mschipperheyn opened this issue Jul 9, 2015 · 4 comments
Closed

password field no longer hides input #39

mschipperheyn opened this issue Jul 9, 2015 · 4 comments

Comments

@mschipperheyn
Copy link

I just upgraded to 0.2.2 and I noticed that the password field doesn't seem to hide input anymore. My config:

j_password:{
  label:i8n.getMessage('ui.password'),
  placeholder:i8n.getMessage('ui.password'),
  error: i8n.getMessage('errors.password'),
  password:true
}
@gcanti
Copy link
Owner

gcanti commented Jul 10, 2015

This is my test case and it works fine:

  • tcomb-form-native v0.2.2
  • react-native v0.5.0
  • XCode 6.2
  • IOS Simulator 8.2 (iPhone 6)

Which version of react-native are you using?

'use strict';

var React = require('react-native');
var t = require('.');
var stylesheet = require('./lib/stylesheets/bootstrap');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
  TextInput
} = React;

var Form = t.form.Form;

var Credentials = t.struct({
  username: t.Str,
  password: t.Str
});

var AwesomeProject = React.createClass({

  getInitialState() {
    return {
      value: {},
      options: {
        fields: {
          password: {
            label: 'mylabel',
            placeholder: 'my placeholder',
            error: 'my error',
            password: true
          }
        }
      }
    };
  },

  onChange(value) {
    this.setState({value});
  },

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

  render() {
    return (
      <View style={styles.container}>
        <Form
          ref="form"
          type={Credentials}
          options={this.state.options}
          value={this.state.value}
          onChange={this.onChange}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 50,
    padding: 20,
    //backgroundColor: '#333333'
    backgroundColor: '#ffffff'
  },
  title: {
    fontSize: 30,
    alignSelf: 'center',
    marginBottom: 30
  },
  buttonText: {
    fontSize: 18,
    color: 'white',
    alignSelf: 'center'
  },
  button: {
    height: 36,
    backgroundColor: '#48BBEC',
    borderColor: '#48BBEC',
    borderWidth: 1,
    borderRadius: 8,
    marginBottom: 10,
    alignSelf: 'stretch',
    justifyContent: 'center'
  }
});

AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);

@mschipperheyn
Copy link
Author

Hmm, weird. I'm on
react-native v.0.6.0 (the problem occurred after upgrading)
IOS Simulator 8.2 (iPhone 6, tried a variety of deployment targets)

@eyaleizenberg
Copy link

@mschipperheyn you need to add secureTextEntry so it looks like this

password: {
      password: true,
      secureTextEntry: true
}

@mschipperheyn
Copy link
Author

ah ok. I wasn't aware of that. Ah, ok. This allows you to implement a "show password" feature

@gcanti gcanti closed this as completed Jul 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants