3
votes

How do I access a field inside of a field group on the user profile form?
Inside of my custom module, I am able to modify the account name and email no problem using the code below.

$form['account']['name']['#description'] = 'Enter a username';
$form['account']['mail']['#description'] = 'Enter a valid email address';

This does not work to modify a field inside of the personal information field group:

$form['Personal information']['profile_name']['#description'] = 'Enter a valid email address';

The part of the array that I am trying to access is below.

[Personal information] => Array
    (
        [#type] => fieldset
        [#title] => Personal information
        [#weight] => 1
        [profile_name] => Array
            (
                [#type] => textfield
                [#title] => First name
                [#default_value] => 
                [#maxlength] => 255
                [#description] => Enter your first name. The content of this field is kept private and will not be shown publicly.
                [#required] => 1
                [#input] => 1
1
What version of Drupal is this? Are you using Profile 2 module (drupal.org/project/profile2)? - m4olivei
I don't think the problem is accessing a field inside a fieldgroup. My guess is that there is something preventing the function to apply to the proper form. You may be using a rule to apply this change if the form has a name and it may have another one. Are you using Devel module? If so, are you using dpm() to print the $form to the screen? I guess there will be more than one form. - ndvo

1 Answers

0
votes

I think that if you must find in the $form object the 'submitted' array and change the data in there.

so for example:

$form['account']['mail']['#description'] = 'Enter a valid email address';

bocome this (in my case):

$form['submitted']['account']['mail']['#description'] = 'Enter a valid email address';