0

I have created a multiple selection list in registeration form so on the registeration.xml i have pasted this code

<field name="groupMember"
            type="list"
            description="choose cybertechnos groups"
            filter="username"
            label="Choose Groups"
            multiple ="true"
            >

 <option value ="A">A</option>
                <option value ="B">B</option>
                <option value ="C">C</option>
     </field> 

I have also defined its variable in the JUser user.php file like below

    public $groupMember = null;

Now user is able to register fine but the saved value displays only single text "Array" seems like there is nothing except Array coming from the form.

I have var_dump the value on register function of com_users\models\registeration.php

the values display like this

["groupMember"]=> string(5) "Array"

array(8) { ["groupMember"]=> string(5) "Array" ["name"]=> string(4) "abcd" ["username"]=> string(4) "abcd"..............etc

seems like i am not getting any real array object.

I am very new in joomla , Kindly help

2 Answers 2

1

You're getting Array because there are multiple, potential values as you're using the multiple="" attribute.

If you use var_dump($groupMember);, you'll see the values inside the array.

To display the value, you will need to use a foreach loop, like so:

foreach ($groupMember as $group)
{
    echo $group . '<br>';
}
1
  • I have var_dump the value on register function of com_users\models\registeration.php the values display like this ["groupMember"]=> string(5) "Array" i need to save the values of the array and i cannot iterate it untill it show the type as Array not the string it self. Seems like the form is sending array but the data displaying array as string not sure what to do Sep 24, 2015 at 14:17
0

I have found it my self , Just need to convert array into string inside the controller class of registration e.g. components/com_users/controllers/registeration.php

inside the function called "register"

 if ( is_array( $requestData['groupMember'] )) {
            $requestData['groupMember'] = implode( ',', $requestData['groupMember'] );
        }

Your Answer

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

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