0

I can add custom fields to the user registration form, if I add the fields to the user profile: admin/config/people/accounts/fields

There is a checkbox "Show on user registraion" which is inactive: enter image description here

The checkbox only gets active if I check "Mandatory field", but some of the fields must not be mandatory. Is that a bug? Is there a workaround (without using module 'Profil2') ?

I'm using Drupal Core 7.28

2 Answers 2

1

I have never encountered such problem before. But since you have such problem then I think the best way is to write a hook_form_alter. And set the required field that you don't want as mandatory to false.

function mymodule_form_alter(&$form, $form_state, $form_id){
switch ($form_id)  {
    case 'registration_form_id': 
                $form['field_name']['und'][0]['value']['#required'] = FALSE;
            break;
                   }
               }

Hope this helps.

1
  • thx, that worked for me
    – scar
    Jun 13, 2014 at 15:15
0

It sounds like something is missing. Both of those options can be found on the field edit page. Both are usually available for checking. However, when you check the 'Required field' option, the 'Display on user registration form' option gets an automatic check and locked (making it virtually impossible to un-check it.) Otherwise when the 'required' option is not checked, the 'Display on user registration form' option should be completely accessible (not automatically checked and available for checking.) If this option is not available (when the 'required' option is not checked,) there may be something wrong with your Drupal Installation.

6
  • Actually I just checked with some other sites and found the same issue. BUT: the checkbox is only deactivated if I add a new field. If I reuse an existing field the checkbox is active. Strange.
    – scar
    Jun 11, 2014 at 14:11
  • DO you mean deactivated at all times, when the other option is checked, or the other option is unchecked?
    – Hoytman
    Jun 11, 2014 at 14:42
  • "show on user registration" is deactivated. It is only active, if "mandatory field" is set. If I uncheck "mandatory field" it is again uncheckable.
    – scar
    Jun 11, 2014 at 15:34
  • DO you have any permissions set that would keep people from using those fields?
    – Hoytman
    Jun 11, 2014 at 15:51
  • Not sure what you mean, if I create the fields new, no custom permission should be set?
    – scar
    Jun 11, 2014 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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