Database Join Default Value

cytino

New Member
Hi
I have a dropdown join to a table with a text field which has a is email validation

I want the join to only show emails belonging to the current user:
For this I have used - where creditor_id='{$my->id}' in the Joins WHERE Statement (sql)

I also need that the default value is the contents of the element - setemail which I hace set as FK.

I have tried return $setemail in the default section with eval on and off with no success.

Any Ideas?
 
Re: "I also need that the default value is the contents of the element - setemail which I hace set as FK."

Not sure what you mean here. Is 'setemail' a column in the main table, or the joined table?

-- hugh
 
table 1 = warning notice
table 2 = ddusers

table 1 (warningnotice) has a dropdown join to table 2 (ddusers) where setemail is the element that I need.

the drop down seems to be working Ok but I cannot get the drop down Default to show the setemail vale as default.
 
So you want the 'setemail' value coresponding to the currently logged in user ($my->id) from the ddusers table?

To do that, you'd need to do a db lookup in the eval'ed default.

-- hugh
 
Same problem for me

Hi Hugh,

could you share how you solved this default value issue on a database join field ? I have the same problem for my federation application where club field (joined to the club table) in the player form should default to the administrator's club who is filling out the form.

Cheers,

Patrick
 
As per our IM conversation, try this:

Hungry Hippo says:
I seem to recall that we are simply missing the 'eval' checkbox under the default text for a join element.
Hungry Hippo says:
but you can finagle that by switching to another element type (like text), enabling 'eval', then switching back to database join.
Hungry Hippo says:
then put your PHP in the default box as usual.
Hungry Hippo says:
it'll look something like this:
Hungry Hippo says:
$sql = "SELECT club_id FROM club_table WHERE admin_id = '$my->id'";
$database->setQuery( $sql );
return $database->loadResult( );

You may need to add "global $my;" as the first line of code, come to think of it.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top