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. Nagtegaal

    Nagtegaal Member

    Level: Community
    You might trying to save a text in a numeric field. Did you use the id?
     
  3. bascherz

    bascherz Member

    Level: Community
    Yes. The field has PHP to fetch the value and label from another table. I can only assume the value is what gets saved, but I don't know the internals of Fabrik. I mean, why else would the "template" PHP be provided showing both the value and label if it doesn't save the value?
     
  4. bascherz

    bascherz Member

    Level: Community
    Finally got a backup of the site to play with and was able to change the data type of the dropdown element's column that won't update from int(11) to text. Made no difference at all.

    Here's the code for the dropdown. Doesn't get much simpler.
    PHP:
    $db = JFactory::getDbo();
    $db->setQuery('SELECT id, name FROM #__district_names ORDER BY name ASC');
    $rows = $db->loadObjectList();
    foreach ($rows as $row) {
        $options[] = JHTML::_('select.option', $row->id, $row->name);
    }
    return $options;
    Additionally:
    • Save to database is set to Yes
    • The primary table involved in this list is also joined in other lists, but they are not linked.
    • There is no autoincrement column on this table (zipcodes).
    • The zip column is the primary key and the element I am trying to update is now type TEXT and not an index (changing to these attributes didn't help).
    • The join is NOT on a primary key column (district) in the main table (zipcodes), but it is joined with the primary key (id) of the other table (district_names).
    • There is no pre-filter on the list or on the instance (menu item).
    • Access control is correct; the item appears to be editable (you can pick from the drop list), but the selected value will not save.
    • No plugins on the list or the menu instance.
    If anyone wants to see a screen shot, there's really only one to show and I described it in bullets above where "join" is described. I have other list elements that use much more complex queries for their dropdown lists, but they don't use joins and they work fine. I've got a feeling it's got something to do with the join.

    I am at a loss on this one. Any additional help would be welcome.

    Thanks in advance. You all have been very gracious thus far.

    Interesting development: So I removed the join from the list since the additional elements from the joined list, although interesting and somewhat helpful, are not essential to the edit the list is trying to provide. After removing the join, I get the following error when I try to save a change:

    It's interesting because other than the PHP I included in this post earlier, I have no code associated with this list. That error is from something internal to Fabrik.
     
    Last edited: Jan 21, 2021

Share This Page