Form Help

TOPIC:

Edit options in Drop Down List 1 year 8 months ago #232444

  • Topic Author
  • ante
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
Hello Mihaela

Thanks.
This time, I face some issues.

1. The first task.
When doing the change as suggested, and then trying the the function it works perfectly. Empty line is removed. But now suddenly the validation rule stops working for that drop down. In the form for this drop down field I use the "valuenotempty" rule from the lib. It works since the value for "Pick a Campaign" is empty. But when saving the textarea field in the other form, this stops working.

2. Second task.
a. Before and After script you have mentioned is the same.
$opts = "0;Pick a Campaign;\n";

b. The code you provided earlier does not match with what you want me to replace now. I tried to replace the foreach loop I have with what you suggest, but that returned an error page when loading the form.
I have:
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $opts.= "0;". $line .";". $line ."\n";
}

Advise?

Best regards,
Ante

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

Edit options in Drop Down List 1 year 8 months ago #232466

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

I've tried to recreate the validation issue, but in my case everything works fine.

Regarding this part of code:
$opts = "0;Pick a Campaign;\n";
you should put it in End Submit pieces instead of this line:
$opts = "";
Sorry for the mistake.

Regarding this part of code:
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $output = "";
    $output = getBetween($line, ';', ';');
   $opts.= $output."\n";
}
I have checked my previous posts and it seems that I have suggested you to put exactly that code in Before Form section, but I think I know what might be the issue. Did you look in End submit instead of Before Form?

I will provide the whole code once more with the changes.

The code in Before Form section should be:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

$db->setQuery("SELECT data2 from #__facileforms_elements WHERE id = 27613"); 
$test = $db->loadResult();

$opts = "";

$tmp = 0;
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    if( $tmp != "0") {
       $output = "";
       $output = getBetween($line, ';', ';');
       $opts.= $output."\n"; }
   $tmp = $tmp + 1;
} 


function getBetween($content,$start,$end){
    $r = explode($start, $content);
    if (isset($r[1])){
        $r = explode($end, $r[1]);
        return $r[0];
    }
    return '';
}

ff_setValue('options', $opts);
NOTE: Don't forget to replace 27613 with the correct ID.

The code in End Submit section should be:
$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 = "0;Pick a Campaign;\n";
foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
    $opts.= "0;". $line .";". $line ."\n";
} 

$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 27613"); 
$db->execute();
NOTE: Once again don't forget to replace 27613 with the correct ID.

Let me know whether you've managed to apply this to your form and whether it works as you wanted.

Regards,

Mihaela
The following user(s) said Thank You: ante

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

Edit options in Drop Down List 1 year 8 months ago #232472

  • Topic Author
  • ante
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
Wow, you really make it easy for me :-)Thanks a lot.
It is not in scope now, but perhaps will be. If I need to add an additional textArea to edit a dropdown in the same form, what do I need to change?

Regarding the validation issue I was able to recreate it a several times yesterday, but now when adding your code correctly it seem gone.

Best regards,
Ante

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

Edit options in Drop Down List 1 year 8 months ago #232481

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

I'm glad I've helped and that the validation issue is gone.

You can use the same code (from Before Form and End Submit) in case you decide to add the Textarea to the form which has the Select list and it will work.

Only thing is that the change you do in textarea won't be presented in select list until you submit the form.

Regards,

Mihaela

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

Edit options in Drop Down List 1 year 8 months ago #232506

  • Topic Author
  • ante
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 63
  • Thanks: 0
Hi

I was thinking if I had all the editable textAreas in one Form. Then I already have the code you have provided in "Before Form" and "End Submit". Would it not collide if i add the entire script again?

I could off-course try it when needed, but I was thinking maybe I could just repeat the unique lines, for instance in the END SUBMIT:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

$test = ff_getSubmit('options');
$test = ff_getSubmit('options2');
$test = ff_getSubmit('options3');
$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";
} 

$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 27613"); 
$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 27614"); 
$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 27615"); 
$db->execute();

Do you think this will work?

Best regards,
Ante

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

Edit options in Drop Down List 1 year 8 months ago #232507

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

Ok, I understand now what you meant.

That code wouldn't work properly because variables would overwrite each other.

The code should look more like this:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library

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

$test = ff_getSubmit('options');
$test1 = ff_getSubmit('options1');
$test2 = ff_getSubmit('options2');

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


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

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

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

$db->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts' WHERE id = 27613"); 
$db1->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts1' WHERE id = 27614"); 
$db2->setQuery("UPDATE #__facileforms_elements SET data2 = '$opts2' WHERE id = 27615");

$db->execute();
$db1->execute();
$db2->execute();

Let me know whether this answers your question.

Regards,

Mihaela
The following user(s) said Thank You: ante

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

Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

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!