1. We apologize for the slow support at the moment. Hugh (cheesegrits) is scheduled for some major back surgery this month to repair two ruptured discs which are severely hampering his ability to work, and one of our stalwart community support members is on vacation for the month. Please bear with us.

database join element/pre-select value

Discussion in 'Subscriber Support' started by treofan, Aug 31, 2007.

Thread Status:
Not open for further replies.
  1. treofan New Member

    Level: Standard
    Hello,

    I'm using a database join element in one of my tables. When adding a new record to the table I can select a value from the drop down list and the value is also displayed later in the table view.

    My problem now is the following:
    When I edit an existing record, the element doesn't display the value which I selected before but 'Please select'. That means I have to select the right value again. Is it not possible to have the element displaying the value according to the record as a pre-selection? Where can I change it?

    Cheers,
    Marcus
  2. cheesegrits Support Gopher

    Level: Community
    Strange, that should be the default behavior. I just double checked on some of my forms, and the joined dropdowns retain their value when editing the forms, or viewing them in tables.

    Check your fabrik.class.php, around line 898 in getForeignKeyDropDowns(), should be ...

    Code (text):
                                $default = $group->getElementDefaultValue( $el, $elementData, $this, $editable );
                                if( $el->canUse( ) ){
                                    /*if user can access the drop down*/
                                   
                                    if( $displayType == "dropdown" ){
                                        $dropdown = mosHTML::selectList( $tmp, $_elHTMLName, 'class="inputbox" size="1" ', 'value', 'text', $default );
                                    } else {
                                        $dropdown = fabrik_html_content::radioList( $tmp, $_elHTMLName, 'class="inputbox" size="1" ', $default,'value', 'text' );
                                    }
                                } else {
    The dropdown is built using the standard Joomla mosHTML::selectList() function, which automagically selects the $default, if that value is found in the values. You might try putting a var_dump() in right after it fetched the default. So right after the first line above, put:

    Code (text):
    echo 'default: '; var_dump($default); echo '<br />';
    ... and see what it prints out when you display the form again.

    -- hugh
  3. treofan New Member

    Level: Standard
    Hi Hugh,

    thanks for your help. At least I couldn't fix the error but now I know where it comes from:

    I joined 2 tables together and used for one of the fields in the second table a join dropdown.

    That seems to confuse fabrik as it gives back a zero value as default when editing the record.
    If I use the join dropdown in the first table everything works fine.

    Any suggestions how to solve the problem?

    Cheers,
    Marcus
  4. rob Administrator

    Level: Community
    Hi Marcus

    This *should* be fixed in rev 184 of the SVN. Could you test it out and let me know if it solves your problem?

    Rob
  5. treofan New Member

    Level: Standard
    Hi Rob,

    it's fixed now. Thanks for you help.

    Cheers,
    Marcus
Thread Status:
Not open for further replies.

Share This Page