Populate select list from joomla frontend.

  • pjfroelofs
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 44
  • Thank you received: 0

pjfroelofs replied the topic: Populate select list from joomla frontend.

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();
#233675
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: Populate select list from joomla frontend.

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
#233678
  • Posts: 156
  • Karma: 1
  • Thank you received: 14

Eddy.vh replied the topic: Populate select list from joomla frontend.

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
#236357
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: Populate select list from joomla frontend.

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
#236358
  • Posts: 156
  • Karma: 1
  • Thank you received: 14

Eddy.vh replied the topic: Populate select list from joomla frontend.

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.
#236360
  • Posts: 2348
  • Karma: 85
  • Thank you received: 315

mihaela replied the topic: Populate select list from joomla frontend.

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
#236364
The following user(s) said Thank You: Eddy.vh
Moderators: ForumSupporttomeperica
Time to create page: 0.091 seconds

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here