Did you know #1 - Multi value display in form


David te Kloese

Kentico has lots of feature and functions to help the developer getting things done easy and quickly. This series will contain quick short posts about handy features and functions to make your developer life more easy.

So quite often when creating a new Page Type you'll have to include a relation to some other item. This could be a Custom Table Item, an other page or perhaps even a User. You don't want to use the related pages.

Easy you think, just create a field and select a 'Custom table item selector' control. (Or the Page/User selector for the other two scenario's I mentioned). And you're done, right?

But what if you want to limit the results, add a where clause, save something else than the default field... You think for two seconds about the drop down menu, radio button or multiple choice field... But end up writing your own custom form control.

Turns out that's not needed. Those three default controls come with lots of features out of the box.

Radio buttons

When you configure the Radio buttons control, you can select the Data source. In this case I needed to select an item from my Locations custom table. But I wanted to show both the Location Name and its type. Since the type will help the editor more to determine which item to select.

Just define the columns you need to display (and the one you want saved in the DB) and put them in the Transformation and Value field as a Macro. Kentico will resolve them on the fly.

 
Radio Button multi value transformation


Note: don't forget to specify all columns you need in your select.

The result could look something like this:
 
Radio button multi value configure
 

Drop-down list

Same way you could configure the drop down menu control.

 
Drop down menu multi value output


You can add extra static content to help display the result. I've put the location between extra parenthesis. But you could also add other things or even complete Kentico macro's to display by your need.

Drop down menu multi value output


 

Multiple choice


Also this can come in handy if you need to make a more advanced selection. Although not that adavnced lets say we want to select all nodes that are published before today of specific page type.

In this case I've configure the Multiple choice control like you can see below.

 
multiple choice value configure

Since the pages can have the same name I've included the Node Alias Path for the editors.


multiple choice value output


There are numerous ways you can extend and configure this to your needs. Lots of scenarios can be solved using this method!