define-form icon indicating copy to clipboard operation
define-form copied to clipboard

Radio Fields

Open LavaToaster opened this issue 6 years ago • 1 comments

When you specify a type="radio" on the field, final-form is able to automatically deal with the checked attribute that radios require. I'm wondering how you'd go able dealing with that with this library.

I.E The following gives ts errors, but is legitimate.

<Row>
  <ResponsiveColumn>
    <Fields.tripType type="radio" value={"single"}>
      {({ input }) => (
        <RadioButton {...input}>
          Single
        </RadioButton>
      )}
    </Fields.tripType>
  </ResponsiveColumn>
  <ResponsiveColumn>
    <Fields.tripType type="radio" value={"annual"}>
      {({ input }) => (
        <RadioButton {...input}>
          Annual
        </RadioButton>
      )}
    </Fields.tripType>
  </ResponsiveColumn>
</Row>

LavaToaster avatar Aug 20 '18 17:08 LavaToaster

(I'm not @ForbesLindesay ) maybe use custom render() func on Fields.tripType ?

<Fields.bio
    render={({ input, meta }) => (
    <div>
        <label>Bio</label>
        <textarea {...input} />
        {meta.touched && meta.error && <span>{meta.error}</span>}
    </div>
    )}
/>

devdoomari3 avatar Sep 06 '18 09:09 devdoomari3