TOPIC:

Dropdown List - Front End Editor 1 year 1 month ago #236346

  • Topic Author
  • multiweb
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 15
  • Thanks: 0
Hi,

We have a client that would like to be able to edit the options in a Dropdown list each day.

My concern is that with all the required info for a dropdown list (0;item;item-alias) that mistakes will be made frequently by the client's staff members.

1) Is there a way to edit the form on the Front End?
2) Is there a way to only edit one field and not any be able to see any of the other fields?
3) Is there a way to automatically populate the other info, eg the number and item-alias? So the client's staff members only have to insert a word and the other required info is automatically populated upon saving?

Any feedback would be great.

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

Dropdown List - Front End Editor 1 year 1 month ago #236351

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

Yes, what you have listed is possible. You could create a separate form in frontend with for example Textarea where select list options will be shown and your client's staff members will be able to edit it.

The form that contains that Dropdown list would have code that would take last submitted value from textarea element in the other form and use entered values as dropdown options.

Take a look at this topic since here the same topic is covered crosstec.org/en/forums/3-breezingforms-f...rontend.html?start=0 .

Let me know whether you have managed to set this for your form.
If you have more questions regarding this, feel free to ask.

Regards,

Mihaela

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

Dropdown List - Front End Editor 1 year 1 month ago #236359

  • Topic Author
  • multiweb
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 15
  • Thanks: 0
Hello again Mihaela,

Thanks for your reply.

How would I edit the below code to get the options list from a completed Text Field in a separate form?
function ff_sel_init(element, condition)
{
        jQuery.ajax({
            type: "GET",
            url: "http://localhost/media/breezingforms/csv/text.csv",  
            success: function(data) {
                //Get values from CSV and split them in Array
                var allValues = data.split(/\r?\n|\r/);

                var redovi = [];
                //Spliting [1]->Yes and [0]->No
                var le = allValues.length;
                for(var i=0; i < le; i++) {
                redovi.push( allValues[i].split(',') );
                        }
                
                //Convert values to JSON string
               var stringConversion = [];
               for(var i=0; i < le; i++) {
                stringConversion.push( JSON.stringify(allValues[i] ) );
                        }


                //Passing JSON string to JSON object for ease of access
                var toJSONObj = [];
                for(var i=0; i < le; i++) {
                toJSONObj.push( JSON.parse(stringConversion[i]) );
                        }

                
                //Do IF statement for Values from Select list and set the proper value
               for(var i=0; i < le; i++) {
               jQuery('#ff_elem23450').append(jQuery('<option>', {
                   value: toJSONObj[i],
                   text: toJSONObj[i]
                })); 
                }

                
            }            
        });

} // ff_sel_init

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

Dropdown List - Front End Editor 1 year 1 month ago #236380

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

A different approach is needed since you wouldn't be fetching data from a CSV file, but you would retrieve it by writing a SQL query.

Please follow instructions form the 4th post in this topic crosstec.org/en/forums/3-breezingforms-f...rontend.html?start=0 . This will work if you are filling in the other form that contains that select list through BreezingForms form.

Let me know whether it worked.

Regards,

Mihaela

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

Dropdown List - Front End Editor 1 year 1 month ago #236428

  • Topic Author
  • multiweb
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 15
  • Thanks: 0
Hi Mihaela,

Thanks for your reply.

I have tried to use the suggested code, however I get an error code in the console.

I have added the code to the already existing code (for the DOB field you helped with), also tried with this specific code on its own and the same error code displays (Uncaught SyntaxError) on the original form.
function ff_registration_init()
{
setInterval(calAge, 500);
} // ff_registration_init

function calAge(){
var dateBirth = ff_getElementByName('dobfield').value;
    var dobParts = dateBirth.split("-");
     var now = new Date();
  var dobParts = dateBirth.split("-");
  var dob = new Date(dobParts[2], (dobParts[1] - 1), dobParts[0]);
  
  var dobYear = dob.getFullYear();
  var dobMonth = dob.getMonth();
  var dobDay = dob.getDate()

  var age = now.getFullYear() - dobYear;
  var ageMonth = now.getMonth() - dobMonth;
  var ageDay = now.getDate() - dobDay;

  if (ageMonth < 0 || (ageMonth == 0 && ageDay < 0)){
    age = parseInt(age) - 1;
  }
    if(age <18) {
        bfToggleFields('on','element','legalguardian',bfDeactivateField);
    }
   else if(age >= 18)  {
        bfToggleFields('off','element','legalguardian',bfDeactivateField);
    }

}

$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

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

$opts = "0;Choose person;\n";

foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
     //   $output = "";
      //  $output = getBetween($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('organiser', $opts);

I have also attatched the package if you don't mind taking a look?

File Attachment:

File Name: registrati...5-30.zip
File Size:23 KB
Attachments:

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

Dropdown List - Front End Editor 1 year 1 month ago #236429

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

This is not working because you have put this piece of code:
$this->execPieceByName('ff_InitLib'); //Include BreezingForms Library
$db = JFactory::getDBO();//Get Database Object

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

$opts = "0;Choose person;\n";

foreach(preg_split("/((\r?\n)|(\r\n?))/", $test) as $line){
     //   $output = "";
      //  $output = getBetween($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('organiser', $opts);
in the Initialization script instead of in Form pieces > Before Form where it should be.

I've placed it in the right place and tested with my element and it is working fine.

Therefore, please place this code in Form pieces > Before Form.

I'm also sending you back your form with the code in the right place.

File Attachment:

File Name: registrati...cted.zip
File Size:19 KB


Let me know whether this is working as you wanted.

Regards,

Mihaela
Attachments:
The following user(s) said Thank You: multiweb

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

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.054 seconds

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!