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

how to add dyamic radio button labels. Labels are not showing in the radio button. #141

Open
amit13091992 opened this issue Apr 13, 2020 · 2 comments

Comments

@amit13091992
Copy link

amit13091992 commented Apr 13, 2020

I am rendering a dynamic form and creating the radio buttons, I am able to get the functionality of radio buttons but the radio button labels are not showing.
Below is my code snippet which I am creating inside a FlatList for dynamic radio buttons creation, but radio labels are not coming.

return (
           <RadioForm
                 initial={0}
                 formHorizontal={false}
                 labelHorizontal={true}
                 buttonColor={'#01AAEF'}
                 animation={true}>
                 {
                     <RadioButton labelHorizontal={true} key={index} >
                                   <RadioButtonInput
                                             obj={rowData}
                                             index={index}
                                             isSelected={this.state.radioIndex === index}
                                             borderWidth={1}
                                             onPress={(value, index) => { this.setState({ value: value }) }}
                                             buttonInnerColor={'#01AAEF'}
                                             buttonOuterColor={this.state.radioIndex === index ? '#01AAEF' : '#000'}
                                             buttonSize={20}
                                             buttonOuterSize={25}
                                             buttonWrapStyle={{ marginLeft: 10 }}
                                                   />
                                             <RadioButtonLabel
                                              obj={'hello'}
                                              index={index}
                                              labelHorizontal={true}
                                              accessibilityLabel={rowData}
                                              onPress={(value, index) => { this.setState({ value: value }) }}
                                              labelStyle={{ fontSize: 20, color: '#01AAEF' }}
                                              labelWrapStyle={{ fontSize: 20, color: '#01AAEF' }}
                                               />
                                       </RadioButton>
                           }
                   </RadioForm>
        );

I have tried with solutions with creating the radio buttons with .map as well but it did not worked. Please provide some solution for my issue. Thanks in advance.

@amit13091992 amit13091992 changed the title how to add dyamic radio button labels. how to add dyamic radio button labels. Labels are not showing in the radio button. Apr 13, 2020
@Foomethod
Copy link

Hi there, not sure if you already found out the reason already or not.

I just recently faced this as well and i found out that RadioButtonLabel renders the label text by using the obj props passed in to them by looking at the node_modules.

Attached below is a snapshot of the RadioButtonLabel component codes (v2.7.4):
Screenshot 2020-07-27 at 3 24 40 PM

Since you are already using flatlist to handle the rendering, in your render component you should do something like this:

...
<RadioButtonLabel
  obj={data.item} // iteration of flatlist's data
  // other button label props...               
/>
...

Also bear in mind that each of your "data.item" should look at least something like this to fulfil the component's requirement:
{ label: "xxx", value: "xxx" }

@vinayzade
Copy link

@amit13091992
Have you got solution, coz I m facing same problem...
Display dynamic data in flatlist radio button
Functionality is working but labels are not showing

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