Dropdown List - Front End Editor

  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb created the topic: Dropdown List - Front End Editor

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.
#236346
  • Posts: 2359
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Dropdown List - Front End Editor

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
#236351
  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Dropdown List - Front End Editor

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
#236359
  • Posts: 2359
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Dropdown List - Front End Editor

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
#236380
  • multiweb
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 0

multiweb replied the topic: Dropdown List - Front End Editor

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
#236428
Attachments:
  • Posts: 2359
  • Karma: 85
  • Thank you received: 316

mihaela replied the topic: Dropdown List - Front End Editor

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
#236429
Attachments:
The following user(s) said Thank You: multiweb
Moderators: ForumSupporttomeperica
Time to create page: 0.073 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the 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