3

I am trying to populate multi selected data on to the user management form below the name field of the user.

Here is what I have added inside the form, in order to display multi selected data from db.

File:

myweb\components\com_users\models\forms\user.xml

<field 
            name="groupMember"
            type="list"
            description="choose cybertechnos groups"
            label="Choose Groups"
            multiple ="true"
            required="true"
            size="111"
            >

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

In order to populate and convert string coma based value into array, I have added the following code inside:

myweb\libraries\joomla\table\user.php

just after load data by query in $data variable inside the load function.

$data["groupMember"] = explode(',', $data["groupMember"]);

But when I check my form inside user management panel, I see two problems.

1) It displays the list with tag style rather than multi selected listbox like below picture.

2) It does not display proper selected values which are coming from the database.

This is the wrong style it shows in the user management list, "Choose Group" enter image description here

I need the below style of "Groups" on user management list enter image description here

1 Answer 1

4

You are doing it completely wrong. Never make core changes to files/classes because there are big chances that you will lose everything on the next CMS update.

Instead use plugins. It is the best way to extend core functionality. What you need here is a simple profile plugin. Read the tutorial Creating a profile plugin.

And if you use a standard list field with a multiple attribute, it will always display options in the tag style (not 100% sure).

Anyway you can create custom form field type to match your requirements.

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.