new CharField([ "label" => "Name", "required" => true, ]), "email" => new EmailField([ "label" => "Email", "required" => true, ]), ]);
new BooleanField([ "label" => "I agree to the terms", "required" => true, ]), ]); if ($form->is_valid()) { // Handle form submission } else { // Display form errors $errors = $form->get_errors(); }This code example shows how to create and validate a form with a single checkbox field that requires user agreement to a set of terms. The `BooleanField` class is used to define the input type and restrictions on the input for the `agree` field. If the form is not valid, the errors can be retrieved using the `get_errors` method. Package library: PHPForm.