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

Radio field never gets touched with MUI - cannot validate #4756

Open
BernardA opened this issue Jan 5, 2022 · 0 comments
Open

Radio field never gets touched with MUI - cannot validate #4756

BernardA opened this issue Jan 5, 2022 · 0 comments
Labels

Comments

@BernardA
Copy link

BernardA commented Jan 5, 2022

Radio field never gets touched

Validation is not triggering as the field never gets touched as in meta.touched. So the form will submit without the required radio button being selected.

Your environment

Software Version(s)
redux-form 7.2.1
redux 4.0.5
react-redux 7.2.1
react 17.0.2
react-dom 17.0.2
node 14.17.3
npm if using 7.19.1
yarn if using
flow if using
typescript if using
Browser Firefog
Operating System Mac OS

Steps to reproduce

The form field:

                     <Field
                        name="isOffer"
                        component={renderRadio}
                        validate={[required]}
                        row
                    >
                        <Radio value="1" label={trans[LANG].offer} />
                        <Radio value="0" label={trans[LANG].request} />
                    </Field>

The renderRadio component:

   export const renderRadio = (field) => {
      const {
         meta: { touched, error },
     } = field;
  return (
    <FormControl>
        <RadioGroup
            aria-label={field.input.name}
            name={field.input.name}
            row={field.row}
            {...field.input}
            {...field.rest}
        >
            {field.children.map((child) => (
                <FormControlLabel
                    key={child.props.value}
                    value={child.props.value}
                    control={<Radio color="primary" />}
                    label={child.props.label}
                />
            ))}
        </RadioGroup>
        <span className="form_error">{touched ? error : ''}</span>
    </FormControl>
   );
};

Expected behaviour

Should trigger validation

Actual behaviour

No validation

Other information

I have checked a few of the issues here like this one or this one, but they do not really address this.

@BernardA BernardA added the bug label Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant