MosesEsan / react-native-basic-form

React Native Basic Form by Moses Esan
3 stars 7 forks source link

Add maxLength property #7

Closed lucj closed 4 years ago

lucj commented 4 years ago

Add maxLength to TextInput

lucj commented 4 years ago

Was not sure about the default value to specify. What do you prefer ? Is 50 chars fine ?

MosesEsan commented 4 years ago

@lucj

Make it conditional

change to

let {autoCapitalize, autoCorrect, clearButtonMode, editable, multiline, keyboardType} = props; let otherProps = {autoCapitalize, autoCorrect, clearButtonMode, editable, multiline, keyboardType} ;

if (props.hasOwnProperty('maxLength')) otherProps = {...otherProps, maxLength: props.maxLength} <Input label={label} value={value} placeholder={placeholder} errorMessage={errorMessage} secureTextEntry={visible} onChangeText={onChangeText} testID={testID}

{...otherProps}

            containerStyle={styles.containerStyle}
            labelStyle={styles.labelStyle}
            errorProps={{testID: `${testID}InputError`}}
        />

Something like this

lucj commented 4 years ago

Ok, I've changed the thing as you suggested. Let me know if this is fine.

lucj commented 4 years ago

Also, do not know if this related to the way the props are passed to the TextInput but with version 1.1.9, I still have the keyboard appearing with Caps lock on for the email-address even if the fields are defined with:

const fields = [
    {name: 'username', label: 'Email Address', required: true, type: 'email-address', autoCapitalize: 'none'},
    {name: 'password', label: 'Password', required: true, secure: true, autoCapitalize: 'none' }
    ];
MosesEsan commented 4 years ago

@lucj Take a look at the documentation

lucj commented 4 years ago

I had no more success with this field's definition (sample from the documentation)

{name: 'username', label: 'Username', required: true, autoCapitalize: "none", autoCorrect: false},

Sorry, I'm really trying to help here.

MosesEsan commented 4 years ago

@lucj You are not defining the fields properly for email type, please take a look at the documentation.

lucj commented 4 years ago

@MosesEsan ok, really sorry for that last part, it seems I did something wrong on my side :( Are you fine with the PR then ?

(BTW, thanks this project is really neat !)