Open OscarBakker opened 8 years ago
react-formal-inputs just specify the type as 'selectlist' https://github.com/jquense/react-formal/issues/42
the above is the generally recommended approach but it does seem benefical to have a built-in Radio input for cases where folks don't want to use react-formal-inputs
I used the addInputTypes
function to configure a Form.Field of type="radio" to use your own or a third party radio button. You can also just specify the type prop on the Form.Field to be your radio button component. I found react-radio-group
to be a nice component that fit my needs. Here's an example of how to use it (es6 syntax). Note that the selectedValue prop on the Form.Field is part of the react-radio-group API.
import React from 'react';
import Form from 'react-formal';
import {RadioGroup, Radio} from 'react-radio-group';
Form.addInputTypes('radio', RadioGroup);
...
render() {
return <Form schema={schema}>
<Form.Field type="radio" name="favorite_fruit" selectedValue={this.state.favorite_fruit}>
<Radio value={fruits.orange}/> Orange
<Radio value={fruits.apple/> Apple
</Form.Field>
</Form>
}
...
Integrating react-formal-inputs into react-formal and supporting modular imports depending on what forms are used would be best?
Any solution? Can I use native radio input out of the box?
Why a simple type='radio'
do not work as expected? The return value are always true
.
First of all, I really like this package. However I'd like to add some radiobuttons within my app. Is there an easy way? (I see them in the react-widgets lib). Would like to hear from you!