TOPIC:

Populate select list from joomla frontend. 1 year 5 months ago #233675

  • Topic Author
  • pjfroelofs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 50
  • Thanks: 0
Hello,
YES it works!

This is so great, many thanks.
One last question.
If I want to populate more then one select list. Is this the right syntax to do that:

$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

$test = ff_getSubmit('bewoners');
$test = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $test);

$opts = "0;Pick a Campaign;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
$opts.= "0;". $line .";". $line ."\n";
}

// breezingform vochtbalans2
$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 2469");
$db->execute();
// breezingform zelfzorgmedicatie
$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 1148");
$db->execute();

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

Populate select list from joomla frontend. 1 year 5 months ago #233678

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
Hello,

I'm glad that I've helped and that it is working for now. :)

To populate two select lists your syntax isn't completely right. Use the following code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object
$db2 = JFactory::getDBO();//Get another Database Object

$test = ff_getSubmit('bewoners');
$test = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $test);

$opts = "0;Pick a Campaign;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
$opts.= "0;". $line .";". $line ."\n";
}

// breezingform vochtbalans2
$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 2469");
$db->execute();
// breezingform zelfzorgmedicatie
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 1148");
$db2->execute();

Let me know whether it works as you wanted.

Regards,

Mihaela

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

Populate select list from joomla frontend. 1 year 1 month ago #236357

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 355
  • Karma: 3
  • Thanks: 59
Hello.

Mihaela,
to go further, how to load a list from a text field that would contain:

name1;email@domaine1.com
name2;email@domaine.de
name3;email@domaine.co.uk

The list would then contain the names of the people and their email value ->

0;name1;email@domaine1.com
0;name2;email@domaine2.de
0;name3;email@domaine3.co.uk

Thank you for the help

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

Populate select list from joomla frontend. 1 year 1 month ago #236358

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
Hello Eddy,

It depends on where would that textfield from which the options would be pulled be placed. Is it an element in other form or is it in the same form?

Also, did you by text field actually mean Textarea or it is a textfield from which option by option would be taken?

Regards,

Mihaela

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

Populate select list from joomla frontend. 1 year 1 month ago #236360

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Gold Breezer
  • Gold Breezer
  • Posts: 355
  • Karma: 3
  • Thanks: 59
Hi Mihaela.

Yes, this is a textarea (so multiline) in another form.

I find the update option from the frontend very interesting.
To test,
I have prepared a form 1 with only an empty list, the script as mentioned at the beginning of the post is in place (changed the ID of the list to match that of the form).
I also prepared a form 2 with a textarea, the validation button, and a script that redirects to Form 1 after submission.
At this point, it works perfectly.

I would now like to be able to fill the list with text and a different value of the text.

I'm just interested in the method, if it's not too long for you to explain ... This allows me to learn a little bit.

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

Populate select list from joomla frontend. 1 year 1 month ago #236364

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
Ok, I think I understand.

In case you want to have different title form option's value and it will be entered in textfield in this format:
title1;value1
title2;value2
title3;value3
then in this piece of code:
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
     //   $output = "";
      //  $output = getBetween($line, ';', ';');
       $opts.= "0;". $line.";". $line."\n"; 
} 
you have to replace
$opts.= "0;". $line.";". $line."\n";
with
$opts.= "0;". $line."\n";

Let me know whether it worked.

Regards,

Miheala
The following user(s) said Thank You: Eddy.vh

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

Moderators: ForumSupport
Time to create page: 0.052 seconds

Summer Sale!

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!