Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

CB field code dropdown single select

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
8 months 1 week ago #337571 by activha
Replied by activha on topic CB field code dropdown single select
Yeah I see but even trying to mapping each value to itself to get the identical keys and values doesn't work with the field.

if I try on a single code field for debugging we get :
Code:
if (isset($data['data']) && is_array($data['data'])) {     $models = [];     foreach ($data['data'] as $model) {         $models[$model] = $model;     }          // This prints the array structure.     echo '<pre>';     print_r($models);     echo '</pre>';     // this outputs :         // Array         // (         //     [neuralDBModel] => neuralDBModel         // )                  return $models;           }

That follows your exemple you gave but if I transform the CB Code field to Code DropDown single select, this fails...

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
8 months 1 week ago #337573 by krileon
Replied by krileon on topic CB field code dropdown single select
Code Drop Down (Single Select) works. It has been tested working. Every example I've provided in my previous replies works. These same examples are available on our demo site as well where they are working. You're welcome to confirm those yourself as well.

I'm sorry, I've nothing further to suggest. Your issue is with your code. Do a var_dump on $data and $models and review its structure. Based on your previous replies $model is an object. Specifically the following.
Code:
{"Value":"neuralDBModel","Label":"neuralDBModel"}

So no that will not work. You need to extract the value and label from that object if that's the case and set them into the expected format as provided earlier.


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.

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

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
8 months 1 week ago #337578 by activha
Replied by activha on topic CB field code dropdown single select
Mmmm I think it's not my code but the way CB code field deals with outside php

When returning $models exactly the same from the file then adding
Code:
$result = []; foreach ($models as $key => $value) {     $result[$key] = $value; } return $result;

Everything displays nicely in the drop down, but I can try anything in the outside php file and there is no way to display correctly in the drop down this way !

Well, solved for me...

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
8 months 1 week ago #337580 by krileon
Replied by krileon on topic CB field code dropdown single select

but I can try anything in the outside php file and there is no way to display correctly in the drop down this way !

External PHP files can have their arrays inserted by returning the include. There are several ways to do this properly and have nothing to do with CB Code Field itself. Typically you'd just set the include to a variable and return the variable and the included PHP file would return its array. It's also possible to do this using ob methods.

Suggest consulting with a developer should you have any further PHP related issues. Please keep in mind we cannot assist you with custom coding.


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.

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

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
8 months 1 week ago #337583 by activha
Replied by activha on topic CB field code dropdown single select
Thanks but I usually can get through now without too much issues. That was a very specific question like I have twice a year :-)

I know about your custom code policy. Would have loved to subscribed to your business membership plan but 6000 $ upfront is way too much for a small company as ours and you don't accept monthly payments.

So we'll keep at developer level plan for now and manage using IA :-)

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

Moderators: beatnantkrileon
Powered by Kunena Forum