jquense / react-formal

Sophisticated HTML form management for React
http://jquense.github.io/react-formal
MIT License
526 stars 52 forks source link

Radiobuttons missing in form.field #51

Open OscarBakker opened 8 years ago

OscarBakker commented 8 years ago

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!

jamesjjk commented 8 years ago

react-formal-inputs just specify the type as 'selectlist' https://github.com/jquense/react-formal/issues/42

jquense commented 8 years ago

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

emilyfeder commented 8 years ago

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>
}
...
kdenz commented 7 years ago

Integrating react-formal-inputs into react-formal and supporting modular imports depending on what forms are used would be best?

sshmyg commented 6 years ago

Any solution? Can I use native radio input out of the box?

vendramini commented 4 years ago

Why a simple type='radio' do not work as expected? The return value are always true.