Hi,
based on your explanation, I'm creating one example exactly as you want.
In the attached file I sent you xml file and one PHP file name 'user_id', please that PHP file replace in your Joomla root, and unzip may example->and install it (BF->Configuration->Package Installer->select this xml file->Install Package).
Step 1:
code of user_id PHP file is:
<?php
define('_JEXEC', 1);
if (file_exists(__DIR__ . '/defines.php'))
{
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
$db = JFactory::getDBO();
$code=$_POST['code']; // the value posted from the AJAX request above
$db->setQuery("SELECT id FROM `fkztj_users` WHERE username='$code' ");
$result = $db->loadResult();
echo ($result);
?>
-Please create PHP file name 'user_id' and insert it in the Joomla root.
Step 2.
In Advanced of Form ->More Options-> Scripts-> Init Script, you can find code:
function ff_QuickForm1948418101_init()
{
setInterval('ff_function1_action()',500);
} // ff_QuickForm1948418101_init
function ff_function1_action()
{
jQuery.ajax({
type: "POST",
url: "<?php return JURI::root(true ); ?>/user_id.php",
data: { code: ff_getElementByName('sl').value},
success: function(data) {
ff_getElementByName('User_id').value=data;
}
});
}
-function ff_QuickForm1948418101_init() -> Instead 'QuickForm1948418101' please insert name of your From (not title).
- data: { code: ff_getElementByName('sl').value}, -> Instead 'sl' insert name of your select list (not title).
- ff_getElementByName('User_id').value=data; -> Instead 'user_id' insert name of your hidden element (In this my example I'm created textfield, and in Advenced of field I turn off them).
Step 3
In Advanced of Form ->More Options-> Form pieces-> Before Form
, you can find code for populate select list from database:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
//Create your own query here
$db->setQuery('Select username From fkztj_users Inner Join fkztj_user_usergroup_map On fkztj_users.id = fkztj_user_usergroup_map.user_id Where fkztj_user_usergroup_map.group_id =8');
$result = $db->loadColumn(); //load the result from the query
$test = "";
for ($i = 0; $i < count($result); $i++)
{
$test .= "0;".$result[$i].";".$result[$i]."\n";
}
function ff_setSelectList($name, $value)
{
global $ff_processor;
for ($r = 0; $r < $ff_processor->rowcount; $r++)
{
$row =& $ff_processor->rows[$r];
if ($row->name==$name)
$row->data2 = $value;
unset($row);
} // for
} // ff_setSelectList
ff_setSelectList('sl', $test);
in this part of code:
$db->setQuery('Select username From fkztj_users Inner Join fkztj_user_usergroup_map On fkztj_users.id = fkztj_user_usergroup_map.user_id Where fkztj_user_usergroup_map.group_id =8');
I've connected two tables 'users' and 'fkztj_user_usergroup_map ' and I set condition 'where', where I searching username under the condition group_id =8, you can change the condition which you want.
-ff_setSelectList('sl', $test); - Instead 'sl' insert name of your select list (not title).
-Please do not forget to change the prefix of the database, in all codes where we use the name of the table, my prefix is 'fkztj_' please replace them with yours. You can find it in your database or Joomla->Dlobal configuration->Server ->Database settings and find field Database Tables Prefix where is noticed prefix.
I hope I explained it well if you get stuck, let me know and I will help you!
If this example ok for you, I can help you that you implement it in your production Form.
Regards,
Mirko
Please download->unzip->and install it (BF->Configuration->Package Installer->select this xml file->Install Package).
And do not forget user_id.php file move in your Joomla root.