1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Details view shows no user date with row id -1, but does when user id entered explicitedly

Discussion in 'Professional Support' started by fabrik_83, Jul 18, 2018.

  1. fabrik_83

    fabrik_83 New Member

    Level: Community
    First post on forum so apologies if this has been covered previously: Rather simple task of showing logged in user info in Details view, but many hours later I've still not figured out why it won't work. Registered users DO show in Fabrik list view, and user detail shows when link from list view is clicked.

    However when making a menu item with Fabrik Details type selected and options set to Row id: -1 and Key name: id, I get no Details data, just field labels:
    View attachment 17369


    If I insert an existing user ID number then the Details page displays user data as it should. Only thing changed is Row id field in Menu item option:

    View attachment 17370

    I'm running
    - Joomla 3.8.10 with System Cache disabled
    - PHP 5.6.3 on shared hosted Apache server
    - Fabrik 3.8.1

    I did try making a Fabrik field of user type, but that returned the Joomla user id, 639, instead of the internal Fabrik id, 8.

    PS: Just tested with print_r($_REQUEST) to Details layout to see if there the was any difference between no data (row id: -1) and forced user (row id: 8) then did compare files with BBedit - exactly the same array values.

    Thanks.
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    For "Row id"=-1 you must set "Key name" to the element storing the Joomla user id (usually an element type userid), not the internalid (holding the primary key).

    Maybe you have to add such an element to your form.
     
  3. fabrik_83

    fabrik_83 New Member

    Level: Community
    Hello Troester,
    If I use the Fabrik element type of user, see grab, it returns the Joomla user ID, not Fabrik user ID:

    View attachment 17372


    When I made a calc element to returned the Fabrik user ID it would display the correct (Fabrik) ID in a list view column, but in the Details form it would only output the variable name, such as {rowid}. Is there another Fabrik element with userid type that I need to download? On Fabrik Download page(s) I don't find it.

    Thanks.
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    Yes, the Joomla user id (there's no "Fabrik user id").

    This is what is Fabrik looking for if you use a form/details view with rowid = -1:
    The Joomla user id of the logged-in user must match the user element in the row you want to display.

    In php code and other places (like prefilters or Data-where of databasejoin elements) you can get the Joomla user id of the logged-in user with the placeholder
    {$my->id}
     
  5. fabrik_83

    fabrik_83 New Member

    Level: Community
    I'm truly confused: I got the current fabrik user id of 8 when I viewed the data in list form. When I write 8 in Row id in menu item option then Details page display user info. When I use -1, or Joomla user id, in this case 639, I get no data returned.

    So I just tried this again:
    1. Created new Fabrik element, type user, Options>User Data: ID:
    View attachment 17374
    2. Copy and paste elements Name, userid_elem, into menu item "Key name" field:

    View attachment 17375

    Still returns empty Details form. What else can I try? Should this be easier?
     
  6. troester

    troester Well-Known Member Staff Member

    Level: Community
    These settings should do.
    But the Joomla user id is only inserted into the record if the user is creating a new record.
    So if you have already existing records (created before you added the userid_elem) there's no user id stored.
    Display your userid_elem in the list to see what is stored.

    You don't need to set "User Data" = ID. It's always storing the J! user id, this setting is defining what should be displayed (name, username, email...).

    Again:
    There's no "Fabrik user id", the id element (type internalid, primary key, autoincrement) is the row id, not related to the Joomla user.
     
  7. fabrik_83

    fabrik_83 New Member

    Level: Community
    Troester,
    OK, just created new registerd user, activated and logged in– no details data. Can I email you login credentials so you can see the settings?

    Many thanks
     
  8. troester

    troester Well-Known Member Staff Member

    Level: Community
  9. fabrik_83

    fabrik_83 New Member

    Level: Community
    Troester - added new credential to My Fabrik Sites. Thanks!
     
  10. troester

    troester Well-Known Member Staff Member

    Level: Community
    In your register list there are only two entries, both with empty userid_element.
    For the user you added in your-site there's no "register" record at all.

    So go and edit these records as an admin (e.g. in the backend), select the correct Joomla user (it may be easier if you set the user element to show the Joomla username or name) and save.
    The userid_elem should only be editable for admins.

    You must set your list access. At the moment everybody can edit any record.
    Set Add = public, view list =registered (if registered users should only be able to see their own record add a prefilter) etc.

    If a guest does register do you want to create a Joomla user automatically? (add a jUser form plugin, but in this case set the userid_elem to be a field element, integer)
     
  11. fabrik_83

    fabrik_83 New Member

    Level: Community
    Thanks for all this. I created the two users using Fabrik juser plugin on Register form, and need to find a way to not have to manually set each register user with Joomla ID.

    Is there user manual covering these points? Or can you direct me to instructions on proper set up of getting Joomla user id into userid_element via registration form. Will I find this topic in the wiki help site? I find the info there about controls and features are too general and rarely explained beyond basic functionality.
     
  12. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    There's a setting in the juser plugin, "User ID Field", in the "Fields" tab, where you specify the element on your form that holds the user ID. The juser plugin will then update that field, after creating the new J! user, with the newly created user ID. This would typically be a hidden field element.

    For non-juser forms (ie. ones people fill in on your site after they have registered), add a 'user' element, which will automatically save the user ID of the logged on user creating the form.

    -- hugh
     
  13. troester

    troester Well-Known Member Staff Member

    Level: Community
    The jUser plugin is not set up correctly:
    the User ID field must not be the record id (id element, primary key), it must be the element storing the Joomla user id (the userid_element which you created afterwards, but this element must be a field or database join (not user)).
    http://fabrikar.com/forums/index.php?wiki/joomla-user-form-plugin/
     
  14. fabrik_83

    fabrik_83 New Member

    Level: Community
    It works now! Thanks guys.

    Just to be clear in case other Fabrik users are having this same issue: I created a Fabrik element of plugin type "user", and then selected this field for the Key name in my Menu item for Details page on the Fabrik Form Options tab:

    View attachment 17428

    Two things that originally stumped me was

    1. The name in the juser wiki instructions show the field as "userid" which looks similar to the name of Fabrik internal id field, "id", which it is not. I added suffix of _elem to new user field to make it easier for me to distinguish it from the internal id field.

    2. The other required fields for the juser plugin– name, username, password, and email– SEND their data to Joomla User record upon creating new user, but the juser "User ID field" (all these fields on "Binds data to Joomla user account" tab of juser plugin) RETRIEVES the Joomla user id and stores it in Fabrik db so it knows which user is currently logged in, yes? I intially assumed (incorrectly) this field would send its data, the Fabrik id number, into Joomla user ID field like the other fields do.

    I notice that if I edit data in Fabrik page it will updates the user info in Joomla User record, but not the reverse. Editing the user name in Joomla User record did not change username in users Fabrik record. Not a requirement for my current project, but wondering how would I bind the fields in both directions, if possible?
     
  15. troester

    troester Well-Known Member Staff Member

    Level: Community
    If you have set up the userid_element correctly and set "Sync on edit" = yes it's updating in both ways:
    On form editing it's loading the current Joomla user settings into the form (so if you've made changes via Joomla's user handling they will show up),
    on form save it will update the Joomla user settings.

    But:
    This is only if you are editing the record and you won't get new users created via Joomla automatically.
    So you should modify or create users in a Fabrik list with a jUser form only via this form.
     
  16. fabrik_83

    fabrik_83 New Member

    Level: Community
    OK, now that I've got the current user Detail page working, thanks to you and Hugh, I'm wondering how the sync option will work when I import users from clients existing db. Should I open a new post for this?
     
  17. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Are you importing into the Fabrik list, with CSV?

    If so, in order to create J! users, you'll have to use the listcsv plugin, which lets you run custom code for each row being imported.

    There's an example of creating users, with instructions on how to customize:

    https://github.com/Fabrik/fabrik/bl...k_list/listcsv/scripts/create_client_user.php

    I haven't run that for a while, so there's a chance it might need some fettling, but it looks like it might still work.

    -- hugh
     
  18. fabrik_83

    fabrik_83 New Member

    Level: Community
    Hi All,
    I'm not having any luck with listcsv plugin. I've modified then selected create_client_user.php script in the plugin after I added tit o Registration list. I've replaced 'changethis' to my full elements name, including table name. Running import from list I get error message of "Sorry the following fields in the CSV File are not found in this table:..." then list of all the csv values.

    View attachment 17440


    Perhaps my csv file isn't set up correctly? Here are the first two rows: the first the header and the second row the first record (of ten, not shown):

    userid_element,name_element,username_element,email_element
    101,JesseConner,jesconner,gene@me.com

    I know Hugh is on vacation this week but hoping for any help from other users or support members. Thanks in advance.
     
  19. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Looks like you don't have the right line ending in your file.

    If you find me on Skype (hugh dot messenger at gmail dot com) and send me the file, I'll try importing it here.

    -- hugh
     
  20. fabrik_83

    fabrik_83 New Member

    Level: Community
    Hugh,
    I've emailed you my csv file and customized import_script.php for listcvs plugin. (Sorry I don't understand what you mean by finding you on Skype.)
    This is a minimum field import–only four fields– I wanted to establish as a test and baseline, but I hope to import another 16-20 fields used in my Fabrik Registration form, so any instructions for this as well would be great. Thanks.
     

Share This Page