• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Dropdown: return ID but not the name

Dropdown: return ID but not the name 10 years 3 months ago #30295

  • web10
  • web10's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hello,
I've a small problem...

I have a database (HikaShop) I would like to fill with a form.

When creating categories, I have to put the ID in the database (But I want to see the name.) ;)

Here is my on the spot:
//<code>
$db =& JFactory::getDBO();
$db->setQuery("SELECT `category_id`,`category_name` FROM `joo_hikashop_category` WHERE `category_type` = 'product' AND `category_name` != 'product category' ORDER BY `category_name` ASC");
$results = $db->loadObjectList();
 
foreach ($results as $res){
$value = $res->category_id;
$label = $res->category_name;
$items[] = $value.' '.$label;
}
return implode("\n",$items);
//</code>

I need only
$res->category_id
for imput in my database but i need to view the name in the dropdown

Do you have any idea how to do?

Thank you very much and good day.

PS : I speak french.. sorry for my english :-)
The administrator has disabled public write access.

Dropdown: return ID but not the name 10 years 3 months ago #30302

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Instead of:
$items[] = $value.' '.$label;

use:
$items[] = $value.'|'.$label;

When trying to get the field label (in emails for example), simply use the text placeholder: {field name here:text}. More details on field configuration here:

https://www.rsjoomla.com/support/documentation/view-article/827-dropdown.html
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: web10

Dropdown: return ID but not the name 10 years 3 months ago #30310

  • web10
  • web10's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Thank you !
I had looked at the documentation but I had not seen: :blush: :blush:

"The selectable items are composed out of two parts: value and label, separated by the pipeline character (|). For example:
Steve Matt|Steve Matt, marketing director.
Using this formula, the selection will display Steve Matt, marketing director, but Steve Matt will be stored into the database."
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!