Is there a way to populate fields from a database table?
In this case, the table that I'm pulling from has the user's Email address in it - this grabs the Email address of the current user and finds that Email in the table I am querying, then populates the field values of the form.
Before Form Piece:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library $db = JFactory::getDBO();//Get Database Object $user = &JFactory::getUser();//Get user Object //Create your own query $db->setQuery('Select name From #__users Where id='.$user->id); $result = $db->loadResult(); //load the result from the query ff_setValue('ElementName', $result); // populate the value in the form. Change ElementName to the real name of your element
The code above is just a sample on how to set up a database query and set the form values in a before form piece. If you want to populate values from the logged in user, you can do this much more quickly by adding the following code directly into the value field of a text element (you do not need any Before Form Piece):
<?php $user = &JFactory::getUser();return $user->name;?>
<?php $user = &JFactory::getUser();return $user->email;?>
Note the second code sample does not work for Eaysmode forms. For Easymode please check the following link