× Form Help

Edit options in Drop Down List

  • ante
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 36
  • Thank you received: 0

ante replied the topic: Edit options in Drop Down List

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
#232444
  • Posts: 1437
  • Karma: 48
  • Thank you received: 188

mihaela replied the topic: Edit options in Drop Down List

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
#232466
The following user(s) said Thank You: ante
  • ante
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 36
  • Thank you received: 0

ante replied the topic: Edit options in Drop Down List

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
#232472
  • Posts: 1437
  • Karma: 48
  • Thank you received: 188

mihaela replied the topic: Edit options in Drop Down List

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
#232481
  • ante
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 36
  • Thank you received: 0

ante replied the topic: Edit options in Drop Down List

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
#232506
  • Posts: 1437
  • Karma: 48
  • Thank you received: 188

mihaela replied the topic: Edit options in Drop Down List

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
#232507
The following user(s) said Thank You: ante
Moderators: ForumSupporttomeperica
Time to create page: 0.074 seconds

New Support System

Dear Customers,

Users with active subscription have support priority which will be dona via ServiceDesk (My Account > Raise a ticket).
FREE Support topics will be answered when AND if there is time.

You can check support guidelines here : here

Regards,
Crosstec 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

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