database join element/pre-select value

Status
Not open for further replies.

treofan

New Member
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
 
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:
							$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:
echo 'default: '; var_dump($default); echo '<br />';

... and see what it prints out when you display the form again.

-- hugh
 
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
 
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
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top