0

I created a module that allows administrators to select a specific user for the module to handle. Problem is, the once a user is selected in the modal, the field displays the user's name and my clients have multiple users with the same/similar names. Is it possible to change the displayed value to be the user's username or email?

Current output:

enter image description here

Desired output:

enter image description here

0

In your <field> declaration, you can use the value_field attribute to specify an alternate column in its current context - e.g. value_field="somethingelse" will use the somethingelse column as the displayed value. See user field documentation here for info.

However, I don't think this will help you achieve what you're looking to do. For this purpose, I'd be inclined to use a SQL field type instead, but that really depends on what your intended purpose is for this field - needs further clarity on your purpose "for the module to handle".

4
  • Doesn't appear to be working. It's a bit complicated, but the intent behind the module is to allow an admin to quick copy a user's details to my component's clientele database. It's certainly not intended behavior for a module, but it is functional.
    – Chaosxmk
    Aug 19 '20 at 12:07
  • 1
    So you need the entire user object, or just the email address? If the latter, a SQL form field type would be the way forward. - docs.joomla.org/SQL_form_field_type
    – Grant G
    Aug 19 '20 at 15:22
  • Technically I only need the email and id, so an SQL form field would theoretically work (just need to scrape up something to get the job done), my worry at this point is that the resulting dropdown (assuming SQL form fields create dropdowns) could potentially have an overwhelming amount of options should the site one day have hundreds of users. The user form field was optimal because it provided a modal with search and pagination.
    – Chaosxmk
    Aug 19 '20 at 15:51
  • 1
    Very true; in which case, you could look at custom fields - docs.joomla.org/J3.x:Adding_custom_fields - where you would start with the base user field type and create your own which does exactly as you need.
    – Grant G
    Aug 19 '20 at 15:53

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.