Try to search your question here, if you can't find : Ask Any Question Now ?

radio button value is not shown when submitting form

HomeCategory: stackoverflowradio button value is not shown when submitting form
bhawya asked 1 week ago

I am using redux form for the form elements. The textfield values are shown when submitting but the radio button values is not shown. When i submit the form, i can get the values for email, pass but not role which is a radio button. I have just used {...input} in the input element because it should be suffice, i think.

Here is how i have done

radio.js

const CardToggle = ({ input, meta: { touched, error }, ...props }) => {
  return (
    <React.Fragment>
      <label>
        <StyledInput {...input} type="radio" />
        <StyledBox>
          <CenterElement>{props.children}</CenterElement>
        </StyledBox>
      </label>
      {touched && error && <span>{error}</span>}
    </React.Fragment>
  );
};

export default CardToggle;


submit = (values, mutation) => {
  console.log('values', values);
  // mutation({ variables: values });
};

<styled.Form
  onSubmit={handleSubmit(val => this.submit(val, mutation))}
>
  <Field name="email" label="Email" component={TextField} />
  <Field name="password" label="Password" component={TextField} />
  <AccountType />
</Styled.Form>

<Grid>
  <Field name="role" component={CardToggle} value="enduser">
    <UserIcon size={60} />
    <Title>End User</Title>
  </Field>
  <Field name="role" component={CardToggle} value="company">
    <CompanyIcon size={60} />
    <Title>Company</Title>
  </Field>
</Grid>
1 Answers
Best Answer
Amit answered 1 week ago
Your Answer

15 + 16 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com