TOPIC:

How to keep selected value after ff_validate_submit 1 month 1 week ago #258513

  • Topic Author
  • JLouis
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Hello,
I am using 'samples' forms (instead of quickModeForms).
All my variables are reseted after ff_validate_submit, and it's OK.

But, I want than the variable 'ServerNo' keep it's value after ff_validate_submit.
How can I do ?

Thank's for your help :)

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

How to keep selected value after ff_validate_submit 1 month 1 week ago #258520

  • Mirec's Avatar
  • Mirec
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 206
  • Karma: 2
  • Thanks: 3
Hello,

I currently working on your problem and I will back as soon as possible with the best solution for it.

Thank you for your patience!
regards!
Mirko

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

How to keep selected value after ff_validate_submit 1 month 1 week ago #258525

  • Mirec's Avatar
  • Mirec
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 206
  • Karma: 2
  • Thanks: 3
Hello,

please go to your form-> Advanced-> More option -> Form pieces and in Before Form select TYPE 'Custom' then below, in the code box insert this code:
$this->execPieceByName('ff_InitLib');

$db = JFactory::getDBO();
$db->setQuery('SELECT  value  FROM fzqtr_facileforms_subrecords  WHERE id=(SELECT max(id) FROM fzqtr_facileforms_subrecords)');
$result = $db->loadResult();

ff_setValue('name', $result);

Note: instead of 'name' put your field name (not title) in which you want to show this.
After submit select list will be populated with the last record saved in your form 'ServerNo'.

Also, fzqtr_facileforms_subrecords is name of table in phpmyadmin (where fzqtr is prefix of my table), please check this in your phpmyadmin, and replace fzqtr with your prefix (prefix_facileforms_subrecords)

Let me know if this works for you

regards!
Mirko

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

Last edit: Post by tihana.krivic.

How to keep selected value after ff_validate_submit 1 month 1 week ago #258572

  • Topic Author
  • JLouis
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Thank's a lot for this code.
It works fine for a 'texterea'.

But, for a 'select list', the value is not displayed.
My list box
1;Serveur;''
0;S1;1
0;S2;2
0;S3;3
If I select S2 for example, ServeorNo=2.
After submit, it displays "serveur" instead of display S2

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

How to keep selected value after ff_validate_submit 1 month 1 week ago #258573

  • Mirec's Avatar
  • Mirec
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 206
  • Karma: 2
  • Thanks: 3
Hello,
this is a little bit more complicated with select-lists and I need a little more time to find a solution, I working on it and I will back as soon as possible.
Thank you for your patience!

regards!
Mirko

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

How to keep selected value after ff_validate_submit 1 month 1 week ago #258580

  • Mirec's Avatar
  • Mirec
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 206
  • Karma: 2
  • Thanks: 3
Hello,


I made one example for you and sent it to you in attach a file, could you please download->unzip->and install it (BF->Configuration->Package Installer->select this XML file->Install Package).


In the example, I use one hidden field which reads the last record in the database from the select field and I use that value from the hidden file in code. (note. the hidden field is not saved data in the database! only fetch data from database).

In you form Go to Advanced -> More Options -> Scripts -> Submitted Script and select type 'Custom', below into boxs code insert dis code:
function ff_QuickForm2063376780_submitted(status, message)
{
    switch (status) {
        case FF_STATUS_OK:

       var rez=ff_getElementByName('name').value;

      if(rez == 1){
                  ff_getElementByName('select').selectedIndex=0;
}
     if(rez == 2){
                  ff_getElementByName('select').selectedIndex=1;
}
   if(rez == 3){
                  ff_getElementByName('select').selectedIndex=2;
}

           break;
        case FF_STATUS_UNPUBLISHED:
        case FF_STATUS_SAVERECORD_FAILED:
        case FF_STATUS_SAVESUBRECORD_FAILED:
        case FF_STATUS_UPLOAD_FAILED:
        case FF_STATUS_ATTACHMENT_FAILED:
        case FF_STATUS_SENDMAIL_FAILED:
        default:
           alert(message);
    } // switch
} // ff_QuickForm2063376780_submitted

Note: Instead 'QuickForm2063376780'in this line code
function ff_QuickForm2063376780_submitted(status, message)
inser name of your form (not title)!

in next piece of code :
  var rez=ff_getElementByName('name').value;

Instead, 'name' insert the name of your hidden field.

In next piece of code :
  if(rez == 6)

Instead of '6' insert the value of your select list which is positioned on the index '0'. And repeat that for all values in the select list (for each value insert correct index). And last saved value in the database of the select list will be displayed in select LIst after reloading the form.

next:

In you form Go to Advanced -> More Options -> Scripts -> Submitted Script and select type 'Custom', below into boxs code insert dis code:
$this->execPieceByName('ff_InitLib');

$db = JFactory::getDBO();

$db->setQuery('SELECT value FROM fzqtr_facileforms_subrecords WHERE id=(SELECT max(id) FROM fzqtr_facileforms_subrecords);');
$result = $db->loadResult();

ff_setValue('name', $result);

in next piece of code :
ff_setValue('name', $result);

Instead, 'name' insert the name of your hidden field.

Next:

Then click on the field of the select list and Go Advanced -> Initscript select type 'Custom' and select 'Form Entry', and below into code box insert this code :
function ff_select_init(element, condition)
{
    switch (condition) {
        case 'formentry':
   var rez=ff_getElementByName('name').value;
      if(rez == 1){
                  ff_getElementByName('select').selectedIndex=1;
}
     if(rez == 2){
                  ff_getElementByName('select').selectedIndex=0;
}
   if(rez == 3){
                  ff_getElementByName('select').selectedIndex=2;
}
            break;
        default:;
    } // switch
} // ff_select_init

in next piece of code :
function ff_select_init(element, condition)

Instead 'select' insert the name of your select list (not title). Rest part of code, insert as is described in upper code.

If you get stuck let me know and I will help you. :)

regards!
Mirko



"Download->unzip->and install it (BF->Configuration->Package Installer->select this XML file->Install Package).

File Attachment:

File Name: mypck_001_...5-07.zip
File Size:7 KB
"
Attachments:

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

Time to create page: 0.051 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

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!