vazco/uniforms

Support indeterminate checkbox

dwidge opened this issue · 2 comments

request

Show an indeterminate checkbox when its value is undefined?

When a boolean value is optional and was never clicked by the user, it submits undefined. If the user clicks the checkbox twice it submits false. If they click a third time, can it become undefined again?

notes

https://css-tricks.com/indeterminate-checkboxes/

https://www.w3schools.com/jsref/prop_checkbox_indeterminate.asp
A checkbox cannot be set to indeterminate state by an HTML attribute - it must be set by a JavaScript.

document.getElementById("myCheck").indeterminate = true;

packages

import ZodBridge from "uniforms-bridge-zod";
import { AutoForm } from "uniforms-mui";
import { AutoForm } from "uniforms-unstyled";

You can, and probably should, implement it by yourself outside of uniforms, since it is not standard behavior. You can simply create custom fields https://uniforms.tools/docs/examples-custom-fields/

Hi @dwidge, as @mariusrak wrote, creating a custom field for such a scenario will be the best approach.