Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

CB Field Plugin that updates a different table.

11 years 2 weeks ago #235334 by thoughtscape
We need a CB Field that updates a table other than the comproflier table.
Basically, we want a multi-select checkbox that stores the selections in a join table that has the user id and another value.

The getField function is working perfectly.

I'm having trouble with the update.
How are the methods in cbFieldHandler called?
I see a number of methods such as
prepareFieldDataSave
commitFieldDataSave
rollbackFieldDataSave

When are these methods invoked?

Thanks in advance!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
11 years 2 weeks ago - 11 years 2 weeks ago #235366 by krileon
You want to store the values the user selects in a separate table or you want to store the values the field has available in a separate table?

If you want to store the values the field has available then you can use CB Query Field and its Query select fieldtypes to pull the values from whatever database table (internal or external) you like.

If you want to store the value the user selects it's best to just join CBs table wherever needed to get the value from _comprofiler. Another simple alternative is to use CB Auto Actions and its query action to push the values from _comprofiler to your other table. The last option, most difficult of course, is to create a new CB fieldtype plugin to do exactly what you're wanting.

When are these methods invoked?

Review cb.core.php for usage examples. You don't need them depending on the type of field you're making. You can also extend existing fields to simplify your plugin even further. For example you can extend the select or checkbox field to simplify your code usage.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 11 years 2 weeks ago by krileon.

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

Moderators: beatnantkrileon
Powered by Kunena Forum