Custom label in list selection box
3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 23, 2015 (RSS)
I have a table called 'workshops' that includes the following fields: num, date, location, title
Next I have another table called 'newsletters' where the client will create newsletters. This is where the client will fill out all the particulars to create the newsletter. As part of this process, it will display a multi-select dropdown list where the client can select which workshops they want to promote in that month's newsletter. Sometimes though, the workshops are exactly the same with the exception of the date. I created the list field using the "Get options from database (advanced)" selection using the following options:
Tablename: workshops
Option Values: num
Option Labels: title
A problem immediately rears its head. For many of the workshops the title is exactly the same. There's no way for the client to tell one from the other when selecting them in the list box. It would be great if I could add more than one label to each selection item. For example, if I have three workshops all called "Investing in Turbulent Times", instead of seeing that indistinguishable label repeated three times i the list box, it would be nice to be able to preface it with the date field so that the selection items read more like:
Nov 12th, 2015: Investing in Turbulent Times
Dec 2nd, 2015: Investing in Turbulent Times
Dec 10th, 2015: Investing in Turbulent Times
This way the client would know which particular workshops they are selecting.
Is there any way to do that besides forcing the client to edit the title of each workshop to include the date?
Thanks in advance.
Jim
Websites That Work
By Daryl - November 23, 2015
Hi Jim,
You can add two or more field values for your list option labels by using "Get options from MySQL query (advance)" instead of "Get options from database (advance)" and use CONCAT() to combine two or more columns.
For example:
SELECT num, CONCAT(DATE_FORMAT(`date`, '%b %D, %Y'), ': ', title)
FROM `<?php echo $TABLE_PREFIX ?>workshops`
Hope this help!
Cheers,
PHP Programmer - interactivetools.com
Daryl,
You're my new hero. Thanks so much. This worked perfectly.
Jim
Websites That Work