1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Dropdown element of a joined list is not saving

Discussion in 'Community' started by bascherz, Jan 13, 2021.

  1. bascherz

    bascherz Member

    Level: Community
    I have a list that is a join of two tables and only one element in the associated form is writeable. The correct people have access, can select from the drop list and can click the save button, but the selected value is not being saved. No error message is output. What would cause this?

    Thanks in advance,
    Bruce
     
  2. juuser

    juuser Active Member

    Level: Community
    Form settings -> Form processing, is "Record in database" set to "Yes"?
    Element settings - > Access, is "Save to database" set to "Yes"?
    No javascript error in browser console?

    If it's a databasejoin element, does it make a difference when you change the value element in databsejoin Data tab.

    I have experienced also a case when the element just gets "broken". So creating a new element and updating with the old element values in PhpMyAdmin has solved the case.
     
    Last edited: Jan 14, 2021
  3. troester

    troester Well-Known Member Staff Member

    Level: Community
    How did you join your tables? One "leg" of the join must be a primary key.
     
    juuser likes this.
  4. bascherz

    bascherz Member

    Level: Community
    Hi troester,

    The tables joined are #__users and #__comprofiler and, indeed, they are joined on the "id" field. There is a third table (a second join) that is used for filtering, but it's still a join, and it is also joined on the primary key for that third table. Is it possible that is interfering? As these are Joomla and Community Builder user profile tables, there is really just the one profile field that needs to be editable in this list. Yes, the field of interest is available via the CB profile editor, but there is a community of site members who need to be able to change it as part of a workaround for a currently crippled/disabled site workflow task. The field is not accessible to the profile owner (it's a control field).

    Many thanks for responding. I sure hope I can get this to work. Needed Monday morning!

    Cheers,
    Bruce

    One other thing... the access level for all the other fields in this list is "Hidden", an access level similar to Guest but used nowhere on the site other than to hide and write-protect things.
     
  5. bascherz

    bascherz Member

    Level: Community
    Hey juuser,

    All those boxes are checked. I've got it setup correctly as far as I can tell. It is NOT a databasejoin element, nor are there any databasejoin elements in the list. The joins (turns out there are THREE) are done in the list "Joins" section.

    [​IMG]

    Also, no Javascript error on the front end, only this error:

    Code (Text):
    You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE' at line 1
    also, following this I also get this message:

    Code (Text):
    Record added/updated
    I've written no SQL myself for this particular list, however the element I need to be editable/savable is implemented as a droplist. It's a CB field that in CB is a single-select radio button field and which I tried to make an integer in Fabrik. However, Fabrik insists on saving droplist elements as TEXT. That's neither here nor there for my purpose, so I allowed it. I don't think that aspect has anything to do with this issue, but it might.

    Finally looking at the list menu item itself, and there's this option labeled "Overwrite List Data" that defaults to "No". I assume since its tooltip says it applies to importing data that's ALL it applies to. I tried changing it to "Yes" and that had zero affect. And speaking of the menu item, there's also this filter there. This filter does work, and there is another menu item with this same list that is not filtered (available to a higher ACL). So I am pretty sure THIS isn't causing the problem.

    [​IMG]
     
    Last edited: Jan 16, 2021
  6. troester

    troester Well-Known Member Staff Member

    Level: Community
    In a (Fabrik) join one column must be a primary key, one column a foreign key.

    1st join: You are joining from #_user.id to #_comprofiler.id which is also a primary key.
    I think you have to join to #_comprofiler.user_id

    3rd join: from cb_zip to zip looks like none is a primary key
     
  7. bascherz

    bascherz Member

    Level: Community
    Actually, zip in the #__zipcodes table is the primary key there. I changed the comprofiler join column to user_id. That made no difference. Still getting the error and still cannot save the record.
     
  8. troester

    troester Well-Known Member Staff Member

    Level: Community
    Enable Fabrik debug and Joomla's system debug.
    Maybe you'll get a better error message.
     
  9. bascherz

    bascherz Member

    Level: Community
    It's a live site and typically has well over 500 users actively using it. I can't enable Joomla debug. Never tried Fabrik debug, though. Had to enable it. Then I quickly discovered it doesn't work with SEF URLs (unless /fabrikdebug/1 works or something). So I kicked-up the message level to Development and I get the following message for what appears to be every single row in the list I loaded (about 14,000 rows).

    Code (Text):
    Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /home/ua820988/public_html/lasagnaloveportal.org/components/com_fabrik/models/element.php on line 997
    Tried saving the record via the form and got the same blast of the above (weird since I am in the form at this point) and the same nondescript MySQL error message.
     
  10. troester

    troester Well-Known Member Staff Member

    Level: Community
    This is only a warning/notice. I assume you are running php7.4 and Fabrik is not php7.4 ready. This may create issus but I don't think this is the reason here.
    Is this really a dropdown element or a database join? Which exact settings?
    If you set other elements of the joined list to be writable, are they saved? Check directly in your database if it's not saved at all or if it's saving to an other/new record in your joined table.
    "Only one element writable": The element holding the primary key of the joined table must be enabled

    If you can't test on your site (even outside working hours) you should consider to create a development copy (make sure to open and resave the Fabrik connection after copying a site). But I don't see why you can't enable Joomla debug for a short time if you can enable error display, both is showing some infos to users.
     
  11. lcollong

    lcollong FabriKant d'applications web

    Level: Community
    BTW, even on a production site you can enable JDebug only for some users groups. So regular users won't see joomla debug output . See system plugin debug for parameters

    upload_2021-1-17_11-38-12.png
     
    troester likes this.
  12. troester

    troester Well-Known Member Staff Member

    Level: Community
    Always learning:)
     
  13. bascherz

    bascherz Member

    Level: Community
    Heh, I didn't even know that Debug Plugin was there. I've always just enabled it in Global Configuration. That said, even with everything enabled (the default) none of that information has ever been helpful in tracking down an issue for me. But thanks for pointing this out. I configured it the way it will maybe someday help me but won't interfere with anyone else's experience.

    Still having that issue, though I abandoned that particular list and found another way to get the feature I needed that doesn't involve Fabrik. But I have another list that is doing the same thing and it's a much simpler example. I will try to post screen shots here in my "down time". This site keeps me extremely busy!
     
  14. bascherz

    bascherz Member

    Level: Community
    Well, I finally figured out what was wrong with this. Turns out you have to set "Save to database" to "YES" for the primary key element of a list in order to save the writeable elements in that list/table presented in the form. That is so non-intuitive since the primary key is not a column in the database table I want to be in the UPDATE part of the query. Rather, it's the column that should appear in the WHERE clause in Fabrik's UPDATE query. Very strange that that turned out to be the issue this whole time. And now it makes sense that it's happening to multiple lists on my site. I just have to remember to keep those elements either hidden or read-only.

    I get the strangest feeling y'all knew this was the issue and were just waiting for me to discover it on my own. ;)
     

Share This Page