[BUG] - Database join with checkbox type

Discussion in 'Standard Support' started by techpoint, Feb 14, 2012.

  1. techpoint New Member

    Level: Community
    Hi, I use Fabrik svn_5848.
    I've found a medium level bug with database join element using checkbox type.

    The issue occurs if you try to modify a row: it doesn't save changes.

    Example:
    A row contains checkbox database join element with "a" and "c" checked values from "a", "b", "c", "d" list values. I want to modify it with no checked values.
    After save "a" and "c" still remains checked, so it doesn't save my choice.
  2. techpoint New Member

    Level: Community
    friendly bump!
  3. techpoint New Member

    Level: Community
    friendly bump
  4. cheesegrits Support Gopher

    Level: Community
    I'm working on this one.

    -- hugh
    1 person likes this.
  5. rob Administrator

    Level: Community
    Hugh did you get anywere with this one?
  6. techpoint New Member

    Level: Community
    Hi, some news?
  7. cheesegrits Support Gopher

    Level: Community
    I see the problem, working on a fix now.

    -- hugh
  8. cheesegrits Support Gopher

    Level: Community
    OK, should be fixed in github.

    -- hugh
  9. techpoint New Member

    Level: Community
    Hi Hug, I've always upgraded Fabrik svn from TortoiseSVN, what is github?
    However, I've downloaded svn 5856 and tested it but problem persists.
    It still saves with a minimum one checked value.
    I sent you a PM with a Jing video.
  10. cheesegrits Support Gopher

    Level: Community
    Ach phfffft, I fixed it in f3, not f2. 3.0 had the same problem.

    Checking the f2 code, which I think is pretty much the same ...

    -- hugh
    1 person likes this.
  11. cheesegrits Support Gopher

    Level: Community
    OK, I think I've back-ported the changes.

    Try out the latest SVN and let me know.

    -- hugh
  12. techpoint New Member

    Level: Community
    Hi Hugh :-/ it doesn't work! Problem persists...

    I remind you that the issue is on database join element using checkbox type.
  13. techpoint New Member

    Level: Community
    friendly bump
  14. kebmsmith Member

    Level: Community
    I was about to post about a problem. Maybe this is the same one. I found that when I try to poll the "checked" value of a checkbox element, the DIV containing the individual checkboxes do not have and ID attribute, so I can't get the element. Is this the same issue?

    I'm going to post the question to a new thread, but if it's fixed by the same bugfix you are talking about, feel free to close it and I'll go figure out how to download the patch.
    --
    Kevin
  15. kebmsmith Member

    Level: Community
    Never mind my addition to this thread. I asked and answered my question here. For anyone else having problems with JavaScript for polling an array of checkboxes, please see:

    http://fabrikar.com/forums/showthread.php?t=25162

    Thanks anyway.
    --
    K
  16. techpoint New Member

    Level: Community
    new friendly bump
  17. techpoint New Member

    Level: Community
    friendly bump!!

    I assumed that the problem was on components\com_fabrik\models\form.php file approx at this code line:

    Code (text):
                    // $$$ rob - erm is $fields needed?
                    //$fields = $listModel->getDBFields($listModel->getTable()->db_table_name);
                    $aKey = $listModel->getPrimaryKeyAndExtra();
                    $aKey = $aKey[0];
                    $listModel->getTable()->db_primary_key = $aKey['colname'];
                    $joinDb =& $listModel->getDb();
                    //back on track
                    $fullforeginKey = $oJoin->table_join.'___'.$oJoin->table_join_key;
                    if (is_array($data) && array_key_exists($fullforeginKey, $data)) {


    So I've tested it by adding a "print_r" and a "die" commands before the "if" statement:
    Code (text):
                    // $$$ rob - erm is $fields needed?
                    //$fields = $listModel->getDBFields($listModel->getTable()->db_table_name);
                    $aKey = $listModel->getPrimaryKeyAndExtra();
                    $aKey = $aKey[0];
                    $listModel->getTable()->db_primary_key = $aKey['colname'];
                    $joinDb =& $listModel->getDb();
                    //back on track
                    $fullforeginKey = $oJoin->table_join.'___'.$oJoin->table_join_key;
            echo "<pre>";
            print_r ($data);
            echo "</pre>";
            die('');
                    if (is_array($data) && array_key_exists($fullforeginKey, $data)) {


    Now, when I modify a row and save it again with all unchecked values it dies and allows me to show the following message:
    Code (text):
    Array (     [table_name___parent_id] => Array         (         )  )


    if I save with at least one checked values it shows:
    Code (text):
    Array (     [table_name___myrow] => Array         (             [0] => 16         )      [table_name___id] => Array         (             [0] => 1         )      [table_name___parent_id] => Array         (         )  )


    Well! Now I think that the "if" statement is wrongly executed when $data is an array, but it is empty so it should skip and execute the "else" statement of the "if"!

    However you can notice that:
    Code (text):
        [table_name___parent_id] => Array         (         )


    ...it seems that array_key_exists($fullforeginKey, $data) always contains $fullforeginKey array key... (is that wrong?)!

    Then, I had thought that the "if" statement would has to be like this:
    Code (text):
    if (is_array($data) && count($data)>1 && array_key_exists($fullforeginKey, $data)) {

    Assuming that it's right that $fullforeginKey is always present inside the $data array, I've added a "count($data)>1" hoping to fix the issue.... but with no luck!!!

    So, regardless of use of "count", it continues to saves datas with the following illogic rule:


    - If you uncheck all values and try to save, it doesn't save changes (so it mantains on db the previously saved datas)!


    I don't know if my argument is wrong, but I really need to fix this annoying problem.
  18. techpoint New Member

    Level: Community
    friendly bump
  19. techpoint New Member

    Level: Community
    friendly bump
  20. rob Administrator

    Level: Community
    Hi

    I've had a go at fixing this, can you update from svn and see if it works for you

    thx
    Rob
    1 person likes this.

Share This Page