Populate select list from joomla frontend.

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

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

I would like to populate a breezingform select list with 15 names of people.
Since those names change in time and I use the same list of people in different breezing forms.
It would be nice to populate them automatically via the joomla frontend. Maybe a joomla article?

In this forum I found a way to populate the select list from the database.
This could work for me, but then I have to find a way to change the people-names in the database from the joomla frontend.

Please advice,
Patrick
#233053
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

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

Hello,

Maybe the best solution for your case would be to have a text or csv file with names and that you change the names there when needed.

Then you could fill in the select list in all the forms with data form that file, so when you change that file it would affect all the select lists.

Please take a look here for that solution crosstec.org/en/forums/1-forums/125248-a....html?start=6#231436

Another solution I would suggest, if you want to populate the names form frontend, would be to create a BreezingForms form with only one element, a Textarea which would contain the people names.
Then you could simply fill the select lists with the latest submitted data in that Textarea element.

Let me know whether this helped.

Regards,

Mihaela
#233128
  • pjfroelofs
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 43
  • Thank you received: 0

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

Hello,
I would really like to populate from the joomla frontend, to give maximum user flexibility.
So your second solution (breezingform with one element) sounds perfect!

This list could look like:
Mr. Johnson
Mr Smith
Mrs Doubt
Mrs etc.

And then this has to be converted and added to a select list in this format:
0;Mr. Johnson;Mr. Johnson
0;Mr Smith;Mr Smith
0;Mrs Doubt;Mrs Doubt
0;Mrs etc.;Mrs etc.

Since I'm not very familiar with the SQL part, could you give me some code how to get this information out of the database?

Thanks for your advice,
Patrick
#233131
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

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

Hello again,

Here is how you could populate the select list with values entered in the Textarea.

After you create a textarea and make a submission with list of names entered go to the end of #__facileforms_subrecords table in database and check that element's ID. You can also get the id from that textarea element by inspecting it.

Then open a form that contains a select list which should be filled in with names from that textarea.
Go to that form's Advanced properties > More options > Form pieces and in Before Form section set Type to Custom.
In the code area below put code similar to this:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

$db->setQuery("SELECT value from #__facileforms_subrecords WHERE element = 1275 ORDER BY id DESC"); 
$test = $db->loadResult();

$opts = "0;Choose person;\n";

foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
     //   $output = "";
      //  $output = getBetween($line, ';', ';');
       $opts.= "0;". $line.";". $line."\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('selectlistname', $opts);
NOTE: In the code area below you have to replace selectlistname with the Name of the select list element that you want to fill with the names.
Also, in SQL query you have to replace 1275 with the ID of textarea element.

Also, you can take a look at this topic crosstec.org/en/forums/35-form-help/1254...wn-list.html?start=6 since here a request similar to yours is resolved.

Let me know whether you've managed to apply this to your form and to fill the select list with values from textarea.

Regards,

Mihaela
#233135
  • pjfroelofs
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 43
  • Thank you received: 0

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

Dear Mihaela,

Thanks for this solution.
I managed to fill the selectlist with a list that can be managed from the frontend.

BUT:
After selecting one of the names in the select list.
This name is NOT saved.
The selectlist field remains empty.

Re Editing the record shows the nicely filled select list.
But once again, selecting one of the persons and saving does not result in any person saved to the database.

When looking at the generated HTML code, all looks very good:

<select data-chosen="no-chzn" class="ff_elem chzn-done" name="ff_nm_Naambewoner[]" id="ff_elem2469">
<option value="">Kies persoon</option>
<option value="Anna Admiraals">Anna Admiraals</option>
<option value="Betty Keizer - Schippers">Betty Keizer - Schippers</option>
<option value="Henk de Koning">Henk de Koning</option>
<option value="Willem de Hertog">Willem de Hertog</option>
<option value="Zaq Bergen">Zaq Bergen</option>
</select>

When I look at your link: Isn’t there any End Submit code required?

Please advice,
Patrick
#233221
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

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

Hello,

The End submit query in the topic that I've linked is not needed in your case, because this works a bit differently.

Could you please send me the code that you have put in the Before Form pieces? So the problem is that even though the select list is filled with options(names) entered in the Textarea, when you submit the form, the selected option isn't recorded, did I understand you correctly?

I have tested the code that I've provided and it is working fine in my case.

Regards,

Mihaela
#233244
Moderators: ForumSupporttomeperica
Time to create page: 0.085 seconds

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

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€

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