CheckboxWithLabel- Yup
See original GitHub issueHi, The label does not appear, nor the error message … I need help please please
import React from 'react'
import { Formik, Field, Form } from 'formik'
import { TextField, CheckboxWithLabel } from 'formik-material-ui'
import * as Yup from 'yup'
const SignupForm = () => {
return (
<Formik
initialValues={{ accept: false }}
validationSchema={Yup.object({
accept: Yup.boolean()
.required('Requis')
.oneOf([true], "Error")
})}
<Form>
<Field
name='accept'
label='condition'
type='checkbox'
component={CheckboxWithLabel}
/>
</Form>
</Formik>
)
}
export default SignupForm
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
CheckboxWithLabel- Yup · Issue #120 · stackworx/formik-mui
It is simply wrapping a label around a CheckboxWithLabel that failed to put a label up, using the FormControlLabel functionality. I believe the ......
Read more >formik-material-ui checkboxes - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >Handling Multiple Checkboxes with Material UI and Formik
I have a form with a checkbox group containing 4 checkboxes within. I need to pass the value to my api on submit...
Read more >Checkboxes Example - Formik
This example demonstrates how to use Formik with a checkbox group. Given that the fields all share the same `name`, Formik will automagically...
Read more >Checkbox Field - Formik for Beginners - Code Daily
Following up with errors and validation. Then we'll dive into building a login form and a registration form, and end the course with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ended up doing this:
@vegtelenseg @Jippay @cliedeman:
The solution above is NOT using the CheckboxWithLabel code to put the label up. It is simply wrapping a label around a CheckboxWithLabel that failed to put a label up, using the FormControlLabel functionality.
I believe the confusion is caused because the sample code in the API documentation is wrong. It shows:
<CheckboxWithLabel name="checked" label="Checkbox" />
^^^^^ which doesn’t work.
What does work is:
<CheckboxWithLabel name="checked" Label={{ label: "Checkbox" }} />
I am not sure if the right thing to do is to change the CheckboxWithLabel component, or the documentation, but clearly changing the documentation would clear up the confusion that exists right now.
– M