I have defined some extra fields for User information in configuration > account settings > manage fields.

One of these fields is of type List (text) and the widget I have chosen for it is Select List.

I want to display this field using Select List widget in Profile Edit Form but as Check boxes/radio buttons in User Register Form.

How can I do so?


By using form_alter hook you can alter the type of field. I am assuming you are using Drupal 7. The below code will alter the field_working_as List (text) profile field in user_register_form in to checkboxes.

And the same field will show as selectbox in profile edit page. I hope this will help you.

function mycustommodule_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'user_register_form') {
  • It worked! but what does the unset function does? – kmdhrm Nov 19 '13 at 7:40
  • It just removed unnecessary '-None-' option from checkboxes list :) – m1r1k Nov 20 '13 at 23:56
  • You should also be using LANGUAGE_NONE instead of 'und'. Or better yet, use the current language – Chaulky Nov 21 '13 at 20:00

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.