TOPIC:

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263708

  • pjfroelofs's Avatar Topic Author
  • pjfroelofs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 59
  • Thanks: 0
Hello
I would like to build a breezingform, with some text fields, a namefield and an (hidden) userid.
My question is about the ‘namefield’.
-- This field should behave like a dropdown selectlist.
-- The field is filled with the joomla usernames, of one specific joomla usergroup.

When the name is chosen from the list.
After submitting the form, automatically the userid of that username is logged into the hidden userid field.

Is this possible?
Please advise,
Patrick

Please Log in or Create an account to join the conversation.

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263709

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 1168
  • Karma: 2
  • Thanks: 62
Hi,

ok,

could you please provide here your Form and I will provide you code for that?

Here on the link below is explained how to create a package:

crosstec.org/en/support/online-documenta...ted/94-packages.html

If you need more help, let me know and I will help you! :)
Regards,
Mirko

Please Log in or Create an account to join the conversation.

Last edit: Post by Mirec.

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263712

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 7381
  • Karma: 3
  • Thanks: 529
Hi @pjfroelofs,

this could help to you how to populate select list with usernames of one specific usergroup:
crosstec.org/en/forums/3-breezingforms-f...ser-group-id-10.html

Let me know if you need more help

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263713

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 1168
  • Karma: 2
  • Thanks: 62
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.

File Attachment:

File Name: mypck_00164.zip
File Size:6 KB
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: Post by Mirec.

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263783

  • pjfroelofs's Avatar Topic Author
  • pjfroelofs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 59
  • Thanks: 0
Is it possible to sort the selectlist alphabetically?
I made some minor changes, like showing the (full) ‘Name’ instead of the ‘Username’.
My last question is how to sort the names in the SelectList?
They are now sorted on account creation date/userid.

I'm totally flabbergasted!
This is beautiful, such an elegant solution, like poetry!
I will renew my subscription, to contribute to your 5 star service!

Regards,
Patrick

Please Log in or Create an account to join the conversation.

Breezingform with a selectlist populated with names of specific joomla usergroup 1 month 1 week ago #263787

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 1168
  • Karma: 2
  • Thanks: 62
Hi,

Is it possible to sort the selectlist alphabetically?


yes, you can do it, in Advanced of Form ->More Options-> Form pieces-> Before Form, where is code for populated of select LIst from the 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, SQL query :
$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');

add these pieces of code in the 'where' condition:
ORDER BY username ASC;

and then code should be like this:
$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 ORDER BY username ASC');

if you want to sort 'name' alphabetically then you should insert it like this:
ORDER BY name ASC

I hope I explained well :)
If you have more questions, feel free to ask!

Regards,
Mirko

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.054 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!