FaridSafi / react-native-gifted-form

📝 « One React-Native form component to rule them all »
MIT License
1.44k stars 214 forks source link

formStyles for ValidationErrorWidget are broken #49

Closed carlinisaacson closed 8 years ago

carlinisaacson commented 8 years ago

When I try to set the styles via formStyles in my GiftedForm component the styles don't change. I did some debugging and when the getStyles function is called from the ValidationErrorWidget this line in the WidgetMixin returns undefined for typeof this.props.formStyles[this.props.type][styleNames[i]].

Also tried changing styles in the example app and there is no change there either.

gabceb commented 8 years ago

The snippet below is working for me to style validationErrorWidgets per widget type

formStyles={{
  TextInputWidget: {
    rowContainer: Styles.textInputRow,
    textInputInline: Styles.textInput,
    validationError: {
      color: 'green'
    },
    validationErrorRow: {
      backgroundColor: 'yellow'
    }
  },
}}
carlinisaacson commented 8 years ago

That is working for me. I was setting it up the way Farid showed in issue #21. I implemented styles like this:

  formStyles={{
    TextInputWidget: {
      rowContainer: Styles.textInputRow,
      textInputInline: Styles.textInput
    },
    ValidationErrorWidget: {
      validationErrorRow: {
        backgroundColor: 'yellow'
      },
      validationError: {
        color: 'green',
      }
    }
  }}

It looks like, because the ValidationErrorWidget is rendered from within the TextInputWidget, the error styles have to go in the text input styles.

Thanks @gabceb. Closing.