× Form Help

Edit options in Drop Down List

  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 3125
  • Karma: 104
  • Thank you received: 410

mihaela replied the topic: Edit options in Drop Down List

Hello,

I have tested the situation and got the same result as you.

I've modified the code and with the following code it is all working fine for me.

In the form that contains textarea with options in Before Form pieces I've put this code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

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

ff_setValue('options', $test);

In End submit of that same form that contains textarea with options I've put this code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db2 = JFactory::getDBO();//Get Database Object
$test = ff_getSubmit('options');

$opts2 = "0;Choose option;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $line = trim($line);
    $line = str_replace(' ', '_', $line);
    $opts2.= "0;". $line .";". $line ."\n";
}
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts2' WHERE id = 267"); 
$db2->execute();

Finally, in Before Form pieces of the form that contains Select list element I've put this code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library

$db = JFactory::getDBO();//Get Database Object

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


$db2 = JFactory::getDBO();//Get Database Object


$opts2 = "0;Choose option;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $line = trim($line);
    $line = str_replace(' ', '_', $line);
    $opts2.= "0;". $line .";". $line ."\n";
}
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts2' WHERE id = 267"); 
$db2->execute();

In the above scripts you need to change the id-s and names of elements as suggested in my previous posts.

Let me know whether you have managed to set this for your form.

Regards,

Mihaela
#234851
  • ante
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 61
  • Thank you received: 0

ante replied the topic: Edit options in Drop Down List

Hello Mihaela, thanks for your answer.

Unfortunately I did not get this to work... Error page on main form, and textArea form did not eliminate blank rows etc. I think maybe because I might have other functions added as well.

Perhaps easier if I show you the code I have:

The Code in the textArea form in Before Form pieces is the same.

But for "End submit of that same form that contains textarea" I currently (before your suggested changes) have:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

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

$opts = "";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $line = trim($line);
    $line = str_replace(' ', '_', $line);
    $opts.= $line ."\n";
}


$db->setQuery("UPDATE #__facileforms_subrecords SET value ='$opts' WHERE element = 98 AND record = (Select Max(id) From #__facileforms_records Where name = 'OptionConfigurations') "); 
$db->execute();


$db2 = JFactory::getDBO();//Get Database Object
$opts2 = "0;Choose option;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $line = trim($line);
    $line = str_replace(' ', '_', $line);
    $opts2.= "0;". $line .";". $line ."\n";
}
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 18"); 
$db2->execute();


Then in the last part " in Before Form pieces of the form that contains Select list element" I currently (before your suggested changes) have:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

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

$opts = "0;Pick a Campaign;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $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('CampaignName', $opts);


Best regards,
Ante
#234857
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 3125
  • Karma: 104
  • Thank you received: 410

mihaela replied the topic: Edit options in Drop Down List

Hello again,

In my previous post this line of code is missing in End Submit pieces:
$test = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $test);
That is why the blank row wasn't eliminated.

Other then that, the suggested code should be working fine. It might be that you didn't set up all the parts correctly.

Either way, after more consideration, I came to conclusion why the existing code isn't saving values as it should and they are not saved to records.

Please in the existing code in "End submit of that same form that contains textarea" in last lines of code instead of
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 18"); 
put this code:
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts2' WHERE id = 18"); 
After you change this, SAVE the change and preview and submit the form containing the TEXTAREA at least once.

Then test the form with the select list and let me know whether this resolves the issue.

Regards,

Mihaela
#234870
  • ante
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 61
  • Thank you received: 0

ante replied the topic: Edit options in Drop Down List

Hello Mihaela

Thank you.

I Changed $opts to $opts2 and it worked only by doing that :-)

I had to do it directly in the database since for some reason since I moved to a new host I can not save any advanced settings for the form with textArea. Normal configuration settings are saved as well as both normal and advanced for the other form. But for some reason with the advanced settings in the textArea form I get an error page with URL ".../administrator/index.php?format=html".

I will post this in a new ticket.

Again, thanks.

Best,
Ante
#234873
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 3125
  • Karma: 104
  • Thank you received: 410

mihaela replied the topic: Edit options in Drop Down List

Hello,

I'm glad that after changing $opts to $opts2 it worked properly. :)
It seems to be a misspell in copying code, but didn't produce an error since this was a filling in the select list in database, but not with right values.

Regarding the new issue, it will be resolved in the new topic then.

Regards,

Mihaela
#234890
Moderators: ForumSupporttomeperica
Time to create page: 0.073 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

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