Form Help

TOPIC:

Edit options in Drop Down List 1 year 3 months ago #234851

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

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

Edit options in Drop Down List 1 year 3 months ago #234857

  • Topic Author
  • ante
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 61
  • Thanks: 0
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

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

Edit options in Drop Down List 1 year 3 months ago #234870

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

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

Edit options in Drop Down List 1 year 3 months ago #234873

  • Topic Author
  • ante
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 61
  • Thanks: 0
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

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

Edit options in Drop Down List 1 year 3 months ago #234890

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 413
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

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

Moderators: ForumSupport
Time to create page: 0.053 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

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!