fateh999/react-native-paper-form-builder

Not working onChange property in select input type

Closed this issue · 5 comments

The 'select' type input does not have a property to trigger an event handler when it changes.
I have tried with onChange into textInputProps, but it won't trigger because this is actually a Menu item with a onDismiss void property that has not been linked to the InputSelect props.

<FormBuilder
  control={control}
  setFocus={setFocus}
  formConfigArray={[
    {
      name: 'favoriteFruit',
      type: 'select',
      textInputProps: {
        label: 'What is you favorite fruit?',
        onChange: fruit =>
          console.log('Your favorite fruit is: ', fruit),
      },
      options: [
        {
          value: 'mango',
          label: 'Mango',
        },
        {
          value: 'banana',
          label: 'Banana',
        },
        {
          value: 'strawberry',
          label: 'Strawberry',
        },
        {
          value: 'pineapple',
          label: 'Pineapple',
        },
        {value: 'other', label: 'Other'},
      ],
      rules: {
        required: {
          value: true,
          message: 'This field is required.',
        },
      },
    },
  ]}
/>

Ok i will add a callback, for this use case

Ok i will add a callback, for this use case

Excellent, thank you Fateh.

Hello Fateh, did you have time to take a look at my PR #32 to add this feature?
I'm really needing this urgent to fix a bug in my application. Thank you very much and have a nice weekend.

Thanks for the PR, i have merged it in the latest release v2.0.6