1

I need to add an "Accept terms and conditions" checkbox onto a user registration form. What is the best way to do this?

Also, it seems odd to me that there is no easy way to use radio buttons nor checkboxes on the User Registration form at admin/config/people/accounts/fields. Select lists are awkward, especially for multi-select lists on a mobile device.

Is there a way to output the list fields as radio buttons and checkboxes?

1
  • hook_form_alter from a custom module into the user registration form and add a '#required' => TRUE '#type' => 'checkbox' element.
    – leymannx
    Nov 18 at 15:58
5

Just add a required boolean field on the User entity (like literally just add this via admin, no code needed). Position it in the Registration form display (see Manage Form Display), but hide it in the view display (i.e. Manage Display). You can use the field help text as fine print.

1
  • Thank you! Not sure why I didn't think of this. Nov 18 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.