Default value to something when using CB Request field

1 year 3 months ago #332293 by activha
Hi,
We have a CB request field working fine but we would like to display an info string when an empty value is returned.
I don't clearly see where I can add this ?
The set up is 
Field /
Request : SELECT e.* FROM `#__groupjive_plugin_events` AS e JOIN `#__groupjive_plugin_events_attendance` AS a on a.`user_id` = '[user_id]' AND a.`event` = e.`id` JOIN `#__groupjive_groups` AS b ON  b.`id` = e.`group` AND ( b.`category` = '13'  OR b.`id` = '56' ) ORDER BY e.`params`ASC
Options : 
Column value : id
Column label : title
Column group : params
Custom group : LANGUAGE_STRING

So when id is empty we'd like to display a message to the user in the dropdown saying "empty" instead of a blank area that they don't know they can click on.

I thought that maybe substitutions in the column value would work and tried to input a string instead of "id" like this :
  'GROUPE_MARKET_COLUMN' => '[cb:if id>0]id[cb:elseif id<=0]Aucun événement[/cb:elseif][/cb:if]'

But it doesn't seem to work.
Can you give me the clue ?

Please Log in to join the conversation.

1 year 3 months ago #332296 by krileon
It should be impossible for id to be empty. That's the auto increment column for that table. Did you mean for title? Suggest just filtering out empty titles in your query directly or extracting the first few characters of the event description in the query to use as title if title is empty.


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 to join the conversation.

1 year 3 months ago #332299 by activha
You are right the id is always a number
But as this is a dropdown request, the first area is an empty space if the user does not want to select any value.
I am simply trying to find a solution to put a name in this empty space (something like "no selection" for instance)

Please Log in to join the conversation.

1 year 3 months ago #332304 by krileon
Ah, ok I understand. You should be able to do that from the options directly under the Global tab of the field. Leave the first option with an empty value then supply a label. That should replace the first empty option with your label. Example as follows

Global > Values
Value: (leave empty)
Label: - Select Option -


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.
The following user(s) said Thank You: activha

Please Log in to join the conversation.

1 year 1 month ago - 1 year 1 month ago #333032 by activha
I come back quickly on this subject :
The solution works fine to display the label if there is no value.
But when editing the field (ajax or no) and viewing the dropdown list the first value is still empty. Is it possible to fill the first line with an indication ?
In the above example, I use title as the column title. Shouldn't it display Title in the first line ?

EDIT:
On the same field with the same query, I'd also like to display what is stored in params, how can I get this ?
For instance I get the id and the title of a row, and in its params I have : {"drophscat":"50"}
I use this as a group column in the results but would like to display it also.
What is the way to achieve this ? I don't need to store it but only to display it near the title

I tried [label] - [group] in the custom label or the display but it does not work

Please Log in to join the conversation.

1 year 1 month ago - 1 year 1 month ago #333039 by krileon

But when editing the field (ajax or no) and viewing the dropdown list the first value is still empty. Is it possible to fill the first line with an indication ?In the above example, I use title as the column title. Shouldn't it display Title in the first line ?

Looks like a possible bug caused by new filterable feature. Have added a bug ticket and already released a fix.

forge.joomlapolis.com/issues/9135

What is the way to achieve this ? I don't need to store it but only to display it near the title

There isn't one with substitutions. You'll need to CONCAT that in your query itself so the query returns that as the title.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.549 seconds

Facebook Twitter LinkedIn