TOPIC:

Save checkbox group values to db then retrieve them and populate group 1 year 3 weeks ago #247384

  • Topic Author
  • Rokhi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 1
Hi
I have a checkbox group on a BF form with 8 checkboxes.
The form is opened by a logged in user and data completed.

On submit, I want to save the values to a profile table in the same format as they are saved to the form_records table - i.e. comma-delimited string of numbers (2,4,6)

Then, the next time that user opens the form, I want to retrieve those values from that table and repopulate the checkbox group.

What I'd like to know or have a link to instruction for is:

1) should the repopulating be done in the initialization script or the before form piece (can I get to the database from the script)
2) What element naming conventions, functions or object references can I use either in the script or PHP to extract to store and then repopulate the checkbox group.
3) I looked at using ff_setChecked('name','value') in the before form piece to populate the group but don't know which element name format to use for name and what value relates to in a checkbox group. I am assuming I iterate through group elements and setChecked() for each one.

Thanks

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

Save checkbox group values to db then retrieve them and populate group 1 year 3 weeks ago #247386

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6920
  • Karma: 3
  • Thanks: 493
Hi,

to populate a checkbox group with database values you have to use a little bit of PHP in the Before Form piece which you can find here:
crosstec.org/en/support/online-documenta...ct-list-from-db.html
This is example for select list, but it should works also with checkbox group

ff_setChecked('name','value') -> this is only for single checkboxes, not for checkbox group.

Hope this helps

Regards,
Tihana

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

Save checkbox group values to db then retrieve them and populate group 1 year 3 weeks ago #247387

  • Topic Author
  • Rokhi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 1
Thanks for that.

The example will replace the whole group, labels and values, which I don't want to do.

What construct would I use in PHP to iterate through all the group elements to collate the element states and create an output string with the numeric values relating to the items checked - the same as is currently stored in a forms_record. (e.g.2,4,6 where checkboxes 2,4 and 6 are checked)

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

Save checkbox group values to db then retrieve them and populate group 1 year 3 weeks ago #247450

  • Topic Author
  • Rokhi
  • Offline
  • Senior Breezer
  • Senior Breezer
  • Posts: 111
  • Thanks: 1
OK, did a bit more research - you were right. That code does the trick ok - just needed to understand how to use it. Name and value params relate to the actual name and value set up in the form element. (switch;name;value - e.g. 0;name1;value1). Obvious when you think about it!

So now I can save the values to a profile and retrieve them to populate the form.

Thanks for your help

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

  • Page:
  • 1
Time to create page: 0.050 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!